ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-12-29 22:15:04
Exec Total Coverage
Lines: 9418 12392 76.0%
Functions: 395 443 89.2%
Branches: 7496 13031 57.5%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/scc.h"
3 #include "base/zdefs.h"
4 #include <cstring>
5 #include <optional>
6 #include <stdio.h>
7 #include "base/combo.h"
8 #include "base/general.h"
9 #include "base/zc_alleg.h"
10 #include "zc/guys.h"
11 #include "zc/replay.h"
12 #include "zc/zc_ffc.h"
13 #include "zc/zc_subscr.h"
14 #include "zc/zelda.h"
15 #include "base/zsys.h"
16 #include "base/msgstr.h"
17 #include "zc/maps.h"
18 #include "zc/hero.h"
19 #include "subscr.h"
20 #include "zc/ffscript.h"
21 #include "gamedata.h"
22 #include "defdata.h"
23 #include "zscriptversion.h"
24 #include "particles.h"
25 #include "base/zc_math.h"
26 #include "slopes.h"
27 #include "base/qrs.h"
28 #include "base/dmap.h"
29 #include "base/mapscr.h"
30 #include "base/misctypes.h"
31 #include "base/initdata.h"
32 #include "zc/combos.h"
33 #include "iter.h"
34
35 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
36
37 int32_t repaircharge=0;
38 bool adjustmagic=false;
39 bool learnslash=false;
40 int32_t wallm_load_clk=0;
41 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
42 int32_t vhead=0;
43
44 char *guy_string[eMAXGUYS];
45
46 void playLevelMusic();
47
48 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
49 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
50
51 1161175 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
52 {
53 1161175 int32_t c = coord.getInt();
54
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1160898 times.
1161175 if(nearest_half)
55 {
56
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1160898 times.
1160898 if (c < 0)
57 c -= val / 2;
58 1160898 else c += (val/2);
59 1160898 }
60 1161175 c -= c % val;
61 1161175 coord = c;
62 1161175 }
63
64 39573070 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
65 {
66
4/4
✓ Branch 0 taken 39056464 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 39571855 times.
39573070 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
67
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 39541535 times.
39571855 if (y < -176) return true;
68
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39541535 times.
39541535 if (x < -256) return true;
69
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 39541454 times.
39541535 if (x > world_w+256) return true;
70 39541454 return false;
71 39573070 }
72
73 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
74 {
75 return
76 (
77 (y > FFCore.enemy_removal_point[spriteremovalY2])
78 || (y < FFCore.enemy_removal_point[spriteremovalY1])
79 || (x < FFCore.enemy_removal_point[spriteremovalX1])
80 || (x > FFCore.enemy_removal_point[spriteremovalX2])
81 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
82 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
83 );
84 }
85
86 6674 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
87 {
88 6674 x = rx + (x.getInt()/256)*256;
89 6674 y = ry + (y.getInt()/176)*176;
90 6674 }
91
92 namespace
93 {
94 int32_t trapConstantHorizontalID;
95 int32_t trapConstantVerticalID;
96 int32_t trapLOSHorizontalID;
97 int32_t trapLOSVerticalID;
98 int32_t trapLOS4WayID;
99
100 int32_t cornerTrapID;
101 int32_t centerTrapID;
102
103 int32_t rockID;
104 int32_t zoraID;
105 int32_t statueID;
106 }
107
108 440 void identifyCFEnemies()
109 {
110 440 trapConstantHorizontalID=-1;
111 440 trapConstantVerticalID=-1;
112 440 trapLOSHorizontalID=-1;
113 440 trapLOSVerticalID=-1;
114 440 trapLOS4WayID=-1;
115 440 cornerTrapID=-1;
116 440 centerTrapID=-1;
117 440 rockID=-1;
118 440 zoraID=-1;
119 440 statueID=-1;
120
121
2/2
✓ Branch 0 taken 225280 times.
✓ Branch 1 taken 440 times.
225720 for(int32_t i=0; i<eMAXGUYS; i++)
122 {
123
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 224845 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
225280 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
124 435 trapLOSHorizontalID=i;
125
4/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 224834 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 440 times.
225280 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
126 440 trapLOSVerticalID=i;
127
3/4
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 224840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 440 times.
225280 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
128 440 trapLOS4WayID=i;
129
3/4
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 224840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 440 times.
225280 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
130 440 trapConstantHorizontalID=i;
131
3/4
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 224840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 440 times.
225280 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
132 440 trapConstantVerticalID=i;
133
134
3/4
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 224840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 440 times.
225280 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
135 440 cornerTrapID=i;
136
3/4
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 224840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 440 times.
225280 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
137 440 centerTrapID=i;
138
139
3/4
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 224840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 440 times.
225280 if((guysbuf[i].flags&guy_rock) && rockID==-1)
140 440 rockID=i;
141
4/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 224798 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 437 times.
225280 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
142 437 zoraID=i;
143
144
4/4
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 224723 times.
✓ Branch 2 taken 117 times.
✓ Branch 3 taken 440 times.
225280 if((guysbuf[i].flags & guy_fire) && statueID==-1)
145 440 statueID=i;
146 225280 }
147 440 }
148
149 32 int32_t random_layer_enemy(int screen)
150 {
151 32 int32_t cnt=count_layer_enemies(screen);
152 32 mapscr* base_scr = get_scr(screen);
153
154
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
155 {
156 return eNONE;
157 }
158
159 32 int32_t ret=zc_oldrand()%cnt;
160 32 cnt=0;
161
162
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
163 {
164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
165 {
166 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
167
168
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
169 {
170
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
171 {
172
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
173 {
174 32 return layerscreen->enemy[j];
175 }
176
177 108 ++cnt;
178 108 }
179 108 }
180 }
181 }
182
183 return eNONE;
184 32 }
185
186 49 int32_t count_layer_enemies(int screen)
187 {
188 49 int32_t cnt=0;
189
190 49 mapscr* base_scr = get_scr(screen);
191
192
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
193 {
194
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
195 {
196 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
197
198
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
199 {
200
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
201 {
202 420 ++cnt;
203 420 }
204 790 }
205 79 }
206 294 }
207
208 49 return cnt;
209 }
210
211 211789 int32_t hero_on_wall()
212 {
213 211789 zfix lx = Hero.getX();
214 211789 zfix ly = Hero.getY();
215
216
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=world_w-64)
217 {
218
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
219
220
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==world_h-48) return down+1;
221 180473 }
222
223
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=world_h-64)
224 {
225
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
226
227
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==world_w-48) return right+1;
228 172303 }
229
230 210948 return 0;
231 211789 }
232
233 823532 bool tooclose(int32_t x,int32_t y,int32_t d)
234 {
235
2/2
✓ Branch 0 taken 613233 times.
✓ Branch 1 taken 210299 times.
823532 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
236 }
237
238 4170490 bool enemy::overpit() const
239 {
240 // This function (and shadow_overpit) has been broken since it was written, and only
241 // checked the same diagonal of the hitbox, over and over again. The bug is because both
242 // loops used the same variable name.
243 // Checking literally every pixel seems like overkill, so for now let's continue to
244 // do the single diagonal but just once. That's why the outer loop is commented out.
245
246 // for ( int32_t q = 0; q < hxsz; ++q )
247 {
248
2/2
✓ Branch 0 taken 38357256 times.
✓ Branch 1 taken 4142742 times.
42499998 for ( int32_t q = 0; q < hit_height; ++q )
249 {
250 //check every pixel of the hitbox
251
2/2
✓ Branch 0 taken 27748 times.
✓ Branch 1 taken 38329508 times.
38357256 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
252 {
253 //if the hitbox is over a pit, we can't land
254 27748 return true;
255 }
256 38329508 }
257 }
258 4142742 return false;
259 4170490 }
260
261 2738193 bool enemy::shadow_overpit() const
262 {
263 // for ( int32_t q = 0; q < hxsz; ++q )
264 {
265
2/2
✓ Branch 0 taken 33489092 times.
✓ Branch 1 taken 2716589 times.
36205681 for ( int32_t q = 0; q < hit_height; ++q )
266 {
267 //check every pixel of the hitbox
268
2/2
✓ Branch 0 taken 21604 times.
✓ Branch 1 taken 33467488 times.
33489092 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
269 {
270 //if the hitbox is over a pit, we can't land
271 21604 return true;
272 }
273 33467488 }
274 }
275 2716589 return false;
276 2738193 }
277
278 // Returns true iff a combo type or flag precludes enemy movement.
279 9645414 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
280 {
281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9645414 times.
9645414 if(moveflags & move_ignore_blockflags) return false;
282 9645414 int32_t c = COMBOTYPE(dx,dy);
283
4/4
✓ Branch 0 taken 6357351 times.
✓ Branch 1 taken 3288063 times.
✓ Branch 2 taken 1472123 times.
✓ Branch 3 taken 1815940 times.
12933477 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
284
6/6
✓ Branch 0 taken 3263934 times.
✓ Branch 1 taken 6381480 times.
✓ Branch 2 taken 408602 times.
✓ Branch 3 taken 2855332 times.
✓ Branch 4 taken 28668 times.
✓ Branch 5 taken 379934 times.
9645414 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
285
5/6
✓ Branch 0 taken 3379441 times.
✓ Branch 1 taken 6265973 times.
✓ Branch 2 taken 3377564 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 3377564 times.
✗ Branch 5 not taken.
19291592 return c==cPIT || c==cPITB || c==cPITC ||
286
4/6
✓ Branch 0 taken 3377564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3377564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3139583 times.
✓ Branch 5 taken 237981 times.
3377564 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
287 // Block enemies type and block enemies flags
288
2/2
✓ Branch 0 taken 3372288 times.
✓ Branch 1 taken 3134307 times.
237981 combo_class_buf[c].block_enemies&1 ||
289
4/4
✓ Branch 0 taken 3360260 times.
✓ Branch 1 taken 12028 times.
✓ Branch 2 taken 3360013 times.
✓ Branch 3 taken 247 times.
3372288 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
290
4/4
✓ Branch 0 taken 3357316 times.
✓ Branch 1 taken 2697 times.
✓ Branch 2 taken 3357250 times.
✓ Branch 3 taken 66 times.
3360013 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
291 // Check for ladder-only combos which aren't dried water
292
4/4
✓ Branch 0 taken 54223 times.
✓ Branch 1 taken 3303027 times.
✓ Branch 2 taken 53928 times.
✓ Branch 3 taken 295 times.
6714205 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
293 // Check for drownable water
294
4/4
✓ Branch 0 taken 1274561 times.
✓ Branch 1 taken 2082394 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 1272229 times.
3356955 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
295 3382082 }
296
297 // Returns true iff enemy is floating and blocked by a combo type or flag.
298 9073786 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
299 {
300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9073786 times.
9073786 if(moveflags & move_ignore_blockflags) return false;
301
4/4
✓ Branch 0 taken 6934805 times.
✓ Branch 1 taken 2138981 times.
✓ Branch 2 taken 1750538 times.
✓ Branch 3 taken 388443 times.
11212767 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
302
4/4
✓ Branch 0 taken 6949352 times.
✓ Branch 1 taken 2124434 times.
✓ Branch 2 taken 2097157 times.
✓ Branch 3 taken 27277 times.
11198220 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
303
2/2
✓ Branch 0 taken 1265400 times.
✓ Branch 1 taken 7808386 times.
16882172 return ((special==spw_floater)&&
304
2/2
✓ Branch 0 taken 7797980 times.
✓ Branch 1 taken 10406 times.
7808386 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
305
2/2
✓ Branch 0 taken 7797861 times.
✓ Branch 1 taken 119 times.
7797980 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
306
2/2
✓ Branch 0 taken 7790050 times.
✓ Branch 1 taken 7811 times.
7797861 (MAPFLAG(dx,dy)==mfNOENEMY)||
307
2/2
✓ Branch 0 taken 7789795 times.
✓ Branch 1 taken 255 times.
7790050 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
308
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6547266 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
15575586 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
309
2/2
✓ Branch 0 taken 6537677 times.
✓ Branch 1 taken 1248114 times.
7785791 (pit_blocks && ispitfall(dx,dy))));
310 9073786 }
311 // Returns true iff a combo type or flag precludes enemy movement.
312 287854 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
313 {
314 287854 int32_t c = COMBOTYPE(dx,dy);
315 287854 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
316
2/2
✓ Branch 0 taken 35642 times.
✓ Branch 1 taken 252212 times.
287854 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
317
5/6
✓ Branch 0 taken 287834 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 287717 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 287717 times.
✗ Branch 5 not taken.
1085745 return c==cPIT || c==cPITB || c==cPITC ||
318
4/6
✓ Branch 0 taken 287717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 287717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 255757 times.
✓ Branch 5 taken 31960 times.
287717 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
319 // Block enemies type and block enemies flags
320
2/2
✓ Branch 0 taken 287047 times.
✓ Branch 1 taken 255087 times.
31960 combo_class_buf[c].block_enemies&1 ||
321
4/4
✓ Branch 0 taken 285788 times.
✓ Branch 1 taken 1259 times.
✓ Branch 2 taken 285757 times.
✓ Branch 3 taken 31 times.
287047 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
322
4/4
✓ Branch 0 taken 281591 times.
✓ Branch 1 taken 4166 times.
✓ Branch 2 taken 281316 times.
✓ Branch 3 taken 275 times.
285757 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
323 // Check for ladder-only combos which aren't dried water
324
4/4
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 279503 times.
✓ Branch 2 taken 1774 times.
✓ Branch 3 taken 39 times.
562593 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
325 // Check for drownable water
326
4/4
✓ Branch 0 taken 57405 times.
✓ Branch 1 taken 223872 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 28870 times.
281277 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
327 }
328
329 // Returns true iff enemy is floating and blocked by a combo type or flag.
330 144461 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
331 {
332
2/2
✓ Branch 0 taken 142138 times.
✓ Branch 1 taken 2323 times.
144461 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
333 144461 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144461 times.
288922 return ((special==spw_floater)&&
335
2/2
✓ Branch 0 taken 144299 times.
✓ Branch 1 taken 162 times.
144461 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
336
2/2
✓ Branch 0 taken 143664 times.
✓ Branch 1 taken 635 times.
144299 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
337
2/2
✓ Branch 0 taken 140745 times.
✓ Branch 1 taken 2919 times.
143664 (MAPFLAG(dx,dy)==mfNOENEMY)||
338
2/2
✓ Branch 0 taken 140716 times.
✓ Branch 1 taken 29 times.
140745 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
339
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 138395 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
281182 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
340
2/2
✓ Branch 0 taken 138395 times.
✓ Branch 1 taken 2071 times.
140466 (pit_blocks && ispitfall(dx,dy))));
341 }
342
343
5/10
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119192 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 119192 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 119192 times.
✗ Branch 9 not taken.
238384 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
344 119192 {
345
1/2
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
119192 x=X;
346
1/2
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
119192 y=Y;
347
3/6
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119192 times.
✗ Branch 5 not taken.
119192 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
348 119192 id=Id;
349 119192 clk=Clk;
350
1/2
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
119192 floor_y=y;
351 119192 ceiling=false;
352 119192 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
353 119192 grumble = movestatus = posframe = timer = ox = oy = 0;
354
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 119192 times.
✓ Branch 2 taken 119192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119192 times.
✗ Branch 5 not taken.
119192 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
355 119192 did_armos=true;
356 119192 script_spawned=false;
357
358 119192 d = guysbuf + (id & 0xFFF);
359 119192 hp = d->hp;
360 119192 starting_hp = hp;
361 // cs = d->cset;
362 //d variables
363
364 119192 flags=d->flags;
365 119192 flags=d->flags;
366 119192 s_tile=d->s_tile; //secondary (additional) tile(s)
367 119192 type=d->type;
368 119192 dcset=d->cset;
369 119192 cs=dcset;
370
2/2
✓ Branch 0 taken 93048 times.
✓ Branch 1 taken 26144 times.
119192 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
371 119192 dp=d->dp;
372 119192 wdp=d->wdp;
373 119192 wpn=d->weapon;
374 119192 wpnsprite = d-> wpnsprite; //2.6 -Z
375 119192 rate=d->rate;
376 119192 hrate=d->hrate;
377
1/2
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
119192 dstep=d->step;
378 119192 homing=d->homing;
379 119192 dmisc1=d->attributes[0];
380 119192 dmisc2=d->attributes[1];
381 119192 dmisc3=d->attributes[2];
382 119192 dmisc4=d->attributes[3];
383 119192 dmisc5=d->attributes[4];
384 119192 dmisc6=d->attributes[5];
385 119192 dmisc7=d->attributes[6];
386 119192 dmisc8=d->attributes[7];
387 119192 dmisc9=d->attributes[8];
388 119192 dmisc10=d->attributes[9];
389 119192 dmisc11=d->attributes[10];
390 119192 dmisc12=d->attributes[11];
391 119192 dmisc13=d->attributes[12];
392 119192 dmisc14=d->attributes[13];
393 119192 dmisc15=d->attributes[14];
394 119192 dmisc16=d->attributes[15];
395 119192 dmisc17=d->attributes[16];
396 119192 dmisc18=d->attributes[17];
397 119192 dmisc19=d->attributes[18];
398 119192 dmisc20=d->attributes[19];
399 119192 dmisc21=d->attributes[20];
400 119192 dmisc22=d->attributes[21];
401 119192 dmisc23=d->attributes[22];
402 119192 dmisc24=d->attributes[23];
403 119192 dmisc25=d->attributes[24];
404 119192 dmisc26=d->attributes[25];
405 119192 dmisc27=d->attributes[26];
406 119192 dmisc28=d->attributes[27];
407 119192 dmisc29=d->attributes[28];
408 119192 dmisc30=d->attributes[29];
409 119192 dmisc31=d->attributes[30];
410 119192 dmisc32=d->attributes[31];
411
2/2
✓ Branch 0 taken 8227 times.
✓ Branch 1 taken 110965 times.
119192 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
412 {
413 110965 dmisc31 = dmisc32;
414 110965 dmisc32 = 0;
415 110965 }
416 119192 spr_shadow=d->spr_shadow;
417 119192 spr_death=d->spr_death;
418 119192 spr_spawn=d->spr_spawn;
419
420
2/2
✓ Branch 0 taken 4886872 times.
✓ Branch 1 taken 119192 times.
5006064 for(int32_t i=0; i<edefLAST255; i++)
421 4886872 defense[i]=d->defense[i];
422
423 119192 bgsfx=d->bgsfx;
424 119192 hitsfx=d->hitsfx;
425 119192 deadsfx=d->deadsfx;
426 119192 bosspal=d->bosspal;
427
428 119192 frozentile = d->frozentile;
429
430 119192 frozencset = d->frozencset;
431 119192 frozenclock = 0;
432
2/2
✓ Branch 0 taken 1191920 times.
✓ Branch 1 taken 119192 times.
1311112 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
433
434
2/2
✓ Branch 0 taken 2026264 times.
✓ Branch 1 taken 119192 times.
2145456 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
435 //firesfx = 0; //t.b.a -Z
436 119192 isCore = true; //t.b.a
437 119192 parentCore = 0; //t.b.a
438
439 119192 firesfx = d->firesfx;
440
2/2
✓ Branch 0 taken 3814144 times.
✓ Branch 1 taken 119192 times.
3933336 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
441
2/2
✓ Branch 0 taken 3814144 times.
✓ Branch 1 taken 119192 times.
3933336 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
442
443 119192 script = d->script;
444
445
2/2
✓ Branch 0 taken 953536 times.
✓ Branch 1 taken 119192 times.
1072728 for ( int32_t q = 0; q < 8; q++ )
446 {
447 953536 initD[q] = d->initD[q];
448 953536 }
449
450 119192 stickclk = 0;
451 119192 submerged = false;
452 119192 didScriptThisFrame = false;
453 119192 activated_handle = std::nullopt;
454 119192 hitdir = -1;
455 119192 editorflags = d->editorflags; //set by Enemy Editor
456 //Set the drawing flag for this sprite.
457
1/2
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
119192 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
458
459
460
2/2
✓ Branch 0 taken 8927 times.
✓ Branch 1 taken 110265 times.
119192 if(bosspal>-1)
461 {
462
1/2
✓ Branch 0 taken 8927 times.
✗ Branch 1 not taken.
8927 loadpalset(csBOSS,pSprite(bosspal));
463 8927 }
464
465
2/2
✓ Branch 0 taken 54279 times.
✓ Branch 1 taken 64913 times.
119192 if(bgsfx>-1)
466 {
467
1/2
✓ Branch 0 taken 54279 times.
✗ Branch 1 not taken.
54279 cont_sfx(bgsfx);
468 54279 }
469
470
2/2
✓ Branch 0 taken 93048 times.
✓ Branch 1 taken 26144 times.
119192 if(get_qr(qr_NEWENEMYTILES))
471 {
472 93048 o_tile=d->e_tile;
473 93048 frate = d->e_frate;
474 93048 }
475 else
476 {
477 26144 o_tile=d->tile;
478 26144 frate = d->frate;
479 }
480
481 119192 tile=0; //init to 0 here, but set it later.
482
483 119192 scripttile = -1;
484 119192 scriptflip = -1;
485 119192 do_animation = true;
486 119192 immortal = false;
487 119192 noSlide = false;
488 119192 deathexstate = -1;
489
490 119192 hashero=false;
491
492 // If they forgot the invisibility flag, here's another failsafe:
493
4/4
✓ Branch 0 taken 5798 times.
✓ Branch 1 taken 113394 times.
✓ Branch 2 taken 5704 times.
✓ Branch 3 taken 94 times.
119192 if(o_tile==0 && type!=eeSPINTILE)
494
1/2
✓ Branch 0 taken 5704 times.
✗ Branch 1 not taken.
5704 flags |= guy_invisible;
495
496 // step = d->step/100.0;
497 // To preserve the odd step values for Keese & Gleeok heads. -L
498
5/8
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12948 times.
✓ Branch 5 taken 106244 times.
✓ Branch 6 taken 12948 times.
✗ Branch 7 not taken.
119192 if(dstep==62.0) dstep+=0.5;
499
5/8
✓ Branch 0 taken 106244 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106244 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 105545 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
106244 else if(dstep==89) dstep-=1/9;
500
501
5/10
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119192 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 119192 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 119192 times.
✗ Branch 9 not taken.
119192 step = zslongToFix(dstep*100);
502
503
504 119192 item_set = d->item_set;
505 119192 grumble = d->grumble;
506
507
2/2
✓ Branch 0 taken 93553 times.
✓ Branch 1 taken 25639 times.
119192 if(frate == 0)
508 25639 frate = 256;
509
510 119192 leader = itemguy = dying = scored = false;
511 119192 canfreeze = count_enemy = true;
512
1/2
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
119192 mainguy = !(flags & guy_doesnt_count);
513
1/2
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
119192 dir = zc_oldrand()&3;
514
515 //2.6 Enemy Editor Hit and TIle Sizes
516
4/6
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 119153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39 times.
119192 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
517 // al_trace("Enemy txsz:%i\n", txsz);
518
5/6
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 119153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 16 times.
119192 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
519
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 119155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
119192 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
520
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 119155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
119192 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
521
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 119169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
119192 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
522
2/2
✓ Branch 0 taken 119164 times.
✓ Branch 1 taken 28 times.
119192 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
523
2/2
✓ Branch 0 taken 119164 times.
✓ Branch 1 taken 28 times.
119192 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
524 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
525
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 119190 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
119192 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
526
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 119190 times.
119192 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
527 {
528
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
529
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
530 2 }
531
532
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 119190 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
119192 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
533
534 119192 SIZEflags = d->SIZEflags;
535
536
8/10
✓ Branch 0 taken 118941 times.
✓ Branch 1 taken 251 times.
✓ Branch 2 taken 368 times.
✓ Branch 3 taken 118824 times.
✓ Branch 4 taken 368 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 368 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 367 times.
119192 if((wpn==ewBomb || wpn==ewSBomb) && type!=eeOTHER && type!=eeFIRE && (type!=eeWALK || dmisc2 != e2tBOMBCHU))
537 1 wpn = 0;
538
539 //tile should never be 0 after init --Z (failsafe)
540
4/6
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119192 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107998 times.
✓ Branch 5 taken 11194 times.
119192 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
541
542 //Moveflags; for gravity and pit interaction
543 119192 moveflags = d->moveflags;
544
3/4
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17800 times.
✓ Branch 3 taken 101392 times.
119192 if(!can_pitfall(false))
545 {
546 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
547
2/4
✓ Branch 0 taken 17800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17800 times.
✗ Branch 3 not taken.
17800 moveflags &= ~move_can_pitfall;
548
2/4
✓ Branch 0 taken 17800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17800 times.
✗ Branch 3 not taken.
17800 moveflags &= ~move_can_waterdrown;
549 17800 }
550
551 119192 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
552
553 119192 specialsfx = d->specialsfx;
554
1/2
✓ Branch 0 taken 119192 times.
✗ Branch 1 not taken.
119192 weap_data = d->weap_data;
555 119192 }
556
557 118930 enemy::~enemy()
558 118930 {
559
1/2
✓ Branch 0 taken 118930 times.
✗ Branch 1 not taken.
118930 FFCore.destroySprite(this);
560
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 118916 times.
118930 if(hashero)
561 {
562
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 Hero.setEaten(0);
563 14 hashero=false;
564 14 }
565 118930 }
566
567 bool enemy::is_move_paused()
568 {
569 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
570 }
571
572 396782 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
573 {
574 396782 int32_t yg = (special==spw_floater)?8:0;
575 396782 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
576
577
1/2
✓ Branch 0 taken 396782 times.
✗ Branch 1 not taken.
396782 if(input_x == -1000)
578 input_x = dx;
579
1/2
✓ Branch 0 taken 396782 times.
✗ Branch 1 not taken.
396782 if(input_y == -1000)
580 input_y = dy;
581
582
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 396454 times.
793287 if(!(moveflags & move_ignore_screenedge)
583
5/6
✓ Branch 0 taken 396782 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 396706 times.
✓ Branch 4 taken 335178 times.
✓ Branch 5 taken 61528 times.
396782 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
584
4/4
✓ Branch 0 taken 396556 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 396505 times.
✓ Branch 3 taken 51 times.
396706 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
585 328 return true;
586
587
6/6
✓ Branch 0 taken 278162 times.
✓ Branch 1 taken 118292 times.
✓ Branch 2 taken 207763 times.
✓ Branch 3 taken 70399 times.
✓ Branch 4 taken 1967 times.
✓ Branch 5 taken 205796 times.
396454 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
588 {
589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276195 times.
276195 if(ispitfall(dx,dy))
590 return true;
591 276195 }
592
593 396454 bool flying = false;
594 396454 bool cansolid = false;
595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396454 times.
396454 if(moveflags & move_ignore_solidity)
596 cansolid = true;
597
2/4
✓ Branch 0 taken 61519 times.
✓ Branch 1 taken 334935 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
396454 switch(special)
598 {
599 case spw_clipbottomright:
600 if(dy>=128 || dx>=208) return true;
601 break;
602 case spw_clipright:
603 break; //if(input_x>=208) return true; break;
604
605 case spw_wizzrobe: // fall through
606 case spw_floater: // Special case for fliers and wizzrobes - hack!
607 {
608
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61519 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
61519 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
609 {
610 if(dy < 32-yg || dy >= 144) return true;
611 if(dx < 32 || dx >= 224) return true;
612 }
613
3/4
✓ Branch 0 taken 61519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57803 times.
✓ Branch 3 taken 3716 times.
61519 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
614 3716 return true;
615 57803 cansolid = true;
616 57803 flying = true;
617 }
618 57803 }
619
620 392738 dx = TRUNCATE_HALF_TILE(dx);
621 392738 dy = TRUNCATE_HALF_TILE(dy);
622
623
5/6
✓ Branch 0 taken 334935 times.
✓ Branch 1 taken 57803 times.
✓ Branch 2 taken 334935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 298582 times.
✓ Branch 5 taken 36353 times.
392738 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
624
625
4/8
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 356385 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 356385 times.
356385 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
626 return !(moveflags & move_ignore_screenedge);
627
628 // TODO: could this reuse _walkflag?
629
630 //_walkflag code
631 356385 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
632
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
633
2/2
✓ Branch 0 taken 350399 times.
✓ Branch 1 taken 5986 times.
356385 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
634
2/4
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356385 times.
✗ Branch 3 not taken.
356385 if (!s1 || !s1->valid) s1 = s0;
635
3/4
✓ Branch 0 taken 350399 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 350399 times.
✗ Branch 3 not taken.
356385 if (!s2 || !s2->valid) s2 = s0;
636
637 356385 int32_t cpos = COMBOPOS(dx%256, dy%176);
638
2/4
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356385 times.
✗ Branch 3 not taken.
356385 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
639 356385 newcombo c = combobuf[ci];
640
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 newcombo c1 = combobuf[ci1];
641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 356385 times.
356385 newcombo c2 = combobuf[ci2];
642
643 356385 int32_t b=1;
644
2/2
✓ Branch 0 taken 170119 times.
✓ Branch 1 taken 186266 times.
356385 if(dx&8) b<<=2;
645
2/2
✓ Branch 0 taken 167084 times.
✓ Branch 1 taken 189301 times.
356385 if(dy&8) b<<=1;
646
647 #define iwtr(cmb, x, y, shallow) \
648 (shallow \
649 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
650 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
651 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
652
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool wtr = iwtr(ci, dx, dy, false);
653
4/6
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45689 times.
✓ Branch 3 taken 310696 times.
✓ Branch 4 taken 45689 times.
✗ Branch 5 not taken.
356385 bool shwtr = iwtr(ci, dx, dy, true);
654
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool pit = ispitfall(dx,dy);
655
656
6/8
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 236798 times.
✓ Branch 3 taken 119587 times.
✓ Branch 4 taken 236798 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 82587 times.
✓ Branch 7 taken 154211 times.
356385 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
657
6/8
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241968 times.
✓ Branch 3 taken 114417 times.
✓ Branch 4 taken 241968 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 70399 times.
✓ Branch 7 taken 171569 times.
356385 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
658
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool needwtr = (moveflags & move_only_waterwalk);
659
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
660
1/2
✓ Branch 0 taken 356385 times.
✗ Branch 1 not taken.
356385 bool needpit = (moveflags & move_only_pitwalk);
661
662
2/2
✓ Branch 0 taken 57803 times.
✓ Branch 1 taken 298582 times.
356385 if(!cansolid)
663 {
664 298582 int32_t cwalkflag = c.walk & 0xF;
665
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
298582 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
298582 if (s1)
667 {
668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
298582 if (c1.type == cBRIDGE)
669 {
670 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
671 {
672 int efflag = (c1.walk & 0xF0)>>4;
673 int newsolid = (c1.walk & 0xF);
674 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
675 }
676 else cwalkflag &= c1.walk;
677 }
678 298582 else cwalkflag |= c1.walk & 0xF;
679 298582 }
680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298582 times.
298582 if (s2)
681 {
682
2/2
✓ Branch 0 taken 1261 times.
✓ Branch 1 taken 297321 times.
298582 if (c2.type == cBRIDGE)
683 {
684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1261 times.
1261 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
685 {
686 1261 int efflag = (c2.walk & 0xF0)>>4;
687 1261 int newsolid = (c2.walk & 0xF);
688 1261 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
689 1261 }
690 else cwalkflag &= c2.walk;
691 1261 }
692 297321 else cwalkflag |= c2.walk & 0xF;
693 298582 }
694
2/2
✓ Branch 0 taken 50862 times.
✓ Branch 1 taken 247720 times.
298582 if(cwalkflag & b)
695 50862 return true;
696 247720 }
697
3/6
✓ Branch 0 taken 305523 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 305523 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 305523 times.
305523 if(needwtr || needshwtr || needpit)
698 {
699 bool ret = true;
700 if (needwtr && wtr) ret = false;
701 else if (needshwtr && shwtr) ret = false;
702 else if (needpit && pit) ret = false;
703 return ret;
704 }
705
3/4
✓ Branch 0 taken 22544 times.
✓ Branch 1 taken 282979 times.
✓ Branch 2 taken 22544 times.
✗ Branch 3 not taken.
305523 else if(wtr && !canwtr)
706 return true;
707
3/4
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 305400 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
305523 else if(pit && !canpit)
708 return true;
709
710 305523 return false;
711 396782 }
712
713 181035 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
714 {
715
3/4
✓ Branch 0 taken 93117 times.
✓ Branch 1 taken 87918 times.
✓ Branch 2 taken 93117 times.
✗ Branch 3 not taken.
181035 if(!(dx || dy)) return true;
716 181035 zfix bx = x+hxofs, by = y+hyofs; //left/top
717 181035 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
718
4/4
✓ Branch 0 taken 178930 times.
✓ Branch 1 taken 2105 times.
✓ Branch 2 taken 131817 times.
✓ Branch 3 taken 47113 times.
181035 if(!ign_sv && dy < 0) //check gravity
719 {
720
3/4
✓ Branch 0 taken 40102 times.
✓ Branch 1 taken 7011 times.
✓ Branch 2 taken 40102 times.
✗ Branch 3 not taken.
47113 if((moveflags & move_obeys_grav) && isSideViewGravity())
721 return false;
722 47113 }
723
724
2/4
✓ Branch 0 taken 181035 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 181035 times.
181035 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
725
726
3/4
✓ Branch 0 taken 87918 times.
✓ Branch 1 taken 93117 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 87918 times.
181035 if(dx && !dy)
727 {
728
2/2
✓ Branch 0 taken 41442 times.
✓ Branch 1 taken 46476 times.
87918 if(dx < 0)
729 {
730
2/4
✓ Branch 0 taken 41442 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41442 times.
41442 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
731 41442 int mx = (bx+dx).getFloor();
732
2/2
✓ Branch 0 taken 80133 times.
✓ Branch 1 taken 23099 times.
103232 for(zfix ty = 0; by+ty < ry; ty += 8)
733 {
734
2/2
✓ Branch 0 taken 61790 times.
✓ Branch 1 taken 18343 times.
80133 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
735 18343 return false;
736 61790 }
737
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 22475 times.
23099 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
738 624 return false;
739
4/4
✓ Branch 0 taken 18723 times.
✓ Branch 1 taken 3752 times.
✓ Branch 2 taken 18722 times.
✓ Branch 3 taken 1 times.
22475 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
740 1 return false;
741 22474 }
742 else
743 {
744 46476 int mx = (rx+dx).getCeil();
745 46476 int lx = mx-hit_width+1;
746
2/2
✓ Branch 0 taken 79733 times.
✓ Branch 1 taken 23855 times.
103588 for(zfix ty = 0; by+ty < ry; ty += 8)
747 {
748
2/2
✓ Branch 0 taken 57112 times.
✓ Branch 1 taken 22621 times.
79733 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
749 22621 return false;
750 57112 }
751
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 23646 times.
23855 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
752 209 return false;
753
3/4
✓ Branch 0 taken 20207 times.
✓ Branch 1 taken 3439 times.
✓ Branch 2 taken 20207 times.
✗ Branch 3 not taken.
23646 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
754 return false;
755 }
756 46120 }
757
2/4
✓ Branch 0 taken 93117 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93117 times.
93117 else if(dy && !dx)
758 {
759
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 44733 times.
93117 if(dy < 0)
760 {
761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48384 times.
48384 special = (special==spw_clipbottomright)?spw_none:special;
762 48384 int my = (by+dy).getFloor();
763
2/2
✓ Branch 0 taken 76133 times.
✓ Branch 1 taken 23042 times.
99175 for(zfix tx = 0; bx+tx < rx; tx += 8)
764 {
765
2/2
✓ Branch 0 taken 50791 times.
✓ Branch 1 taken 25342 times.
76133 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
766 25342 return false;
767 50791 }
768
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 22759 times.
23042 if(scr_walkflag(rx, my, special, up, bx, my, kb))
769 283 return false;
770
3/4
✓ Branch 0 taken 19000 times.
✓ Branch 1 taken 3759 times.
✓ Branch 2 taken 19000 times.
✗ Branch 3 not taken.
22759 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
771 return false;
772 22759 }
773 else
774 {
775 44733 int my = (ry+dy).getCeil();
776 44733 int ly = my-hit_height+1;
777
2/2
✓ Branch 0 taken 69864 times.
✓ Branch 1 taken 20923 times.
90787 for(zfix tx = 0; bx+tx < rx; tx += 8)
778 {
779
2/2
✓ Branch 0 taken 46054 times.
✓ Branch 1 taken 23810 times.
69864 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
780 23810 return false;
781 46054 }
782
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 20896 times.
20923 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
783 27 return false;
784
3/4
✓ Branch 0 taken 17493 times.
✓ Branch 1 taken 3403 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17493 times.
20896 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
785 return false;
786 }
787 43655 }
788 else //! Untested, and currently unused.
789 {
790 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
791 }
792 89775 return true;
793 181035 }
794
795 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
796 {
797 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
798 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
799
800 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
801
802 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
803 return false;
804 for(zfix ty = 0; by+ty < ry; ty += 8)
805 {
806 for(zfix tx = 0; bx+tx < rx; tx += 8)
807 {
808 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
809 return false;
810 }
811 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
812 return false;
813 }
814 for(zfix tx = 0; bx+tx < rx; tx += 8)
815 {
816 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
817 return false;
818 }
819 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
820 return false;
821 return true;
822 }
823
824 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
825 {
826 auto oxsz = hit_width, oysz = hit_height;
827 if(nwid > -1) hit_width = nwid;
828 if(nhei > -1) hit_height = nhei;
829 bool ret = scr_canplace(dx,dy,special,kb);
830 hit_width = oxsz; hit_height = oysz;
831 return ret;
832 }
833
834 113155 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
835 {
836 113155 bool ret = true;
837
7/8
✓ Branch 0 taken 112634 times.
✓ Branch 1 taken 521 times.
✓ Branch 2 taken 32008 times.
✓ Branch 3 taken 80626 times.
✓ Branch 4 taken 28103 times.
✓ Branch 5 taken 3905 times.
✓ Branch 6 taken 28103 times.
✗ Branch 7 not taken.
113155 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
838 dy = 0;
839 113155 const int scl = 2;
840
4/4
✓ Branch 0 taken 15916 times.
✓ Branch 1 taken 125286 times.
✓ Branch 2 taken 28765 times.
✓ Branch 3 taken 112437 times.
141202 while(abs(dx) > scl || abs(dy) > scl)
841 {
842
2/2
✓ Branch 0 taken 14871 times.
✓ Branch 1 taken 13894 times.
28765 if(abs(dx) > abs(dy))
843 {
844 14871 int32_t tdx = dx.sign() * scl;
845
2/2
✓ Branch 0 taken 14099 times.
✓ Branch 1 taken 772 times.
14871 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
846 14099 dx -= tdx;
847 else
848 {
849
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 387 times.
772 if(earlyret) return false;
850 385 dx = tdx;
851 385 ret = false;
852 }
853 14484 }
854 else
855 {
856 13894 int32_t tdy = dy.sign() * scl;
857
2/2
✓ Branch 0 taken 13168 times.
✓ Branch 1 taken 726 times.
13894 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
858 13168 dy -= tdy;
859 else
860 {
861
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 331 times.
726 if(earlyret) return false;
862 395 dy = tdy;
863 395 ret = false;
864 }
865 }
866 }
867
868
2/2
✓ Branch 0 taken 48813 times.
✓ Branch 1 taken 63624 times.
112437 if(dx)
869 {
870
2/2
✓ Branch 0 taken 45302 times.
✓ Branch 1 taken 18322 times.
63624 if(scr_canmove(dx, 0, special, kb, ign_sv))
871 45302 x += dx;
872 else
873 {
874
2/2
✓ Branch 0 taken 16759 times.
✓ Branch 1 taken 1563 times.
18322 if(earlyret) return false;
875 1563 ret = false;
876 1563 int xsign = dx.sign();
877
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1563 times.
1587 while(scr_canmove(xsign, 0, special, kb, ign_sv))
878 {
879 24 x += xsign;
880 24 dx -= xsign;
881 }
882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1563 times.
1563 if(dx)
883 {
884 1563 dx.doDecBound(0,-9999, 0,9999);
885
3/6
✓ Branch 0 taken 1563 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1563 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1563 times.
✗ Branch 5 not taken.
24270 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
886
2/2
✓ Branch 0 taken 794 times.
✓ Branch 1 taken 21913 times.
22707 if(scr_canmove(val, 0, special, kb, ign_sv))
887 {
888 794 retval = val;
889 794 return BSEARCH_CONTINUE_AWAY0;
890 }
891 21913 else return BSEARCH_CONTINUE_TOWARD0;
892 22707 });
893 1563 x += dx;
894 1563 }
895 }
896 46865 }
897
2/2
✓ Branch 0 taken 33883 times.
✓ Branch 1 taken 61795 times.
95678 if(dy)
898 {
899
2/2
✓ Branch 0 taken 42811 times.
✓ Branch 1 taken 18984 times.
61795 if(scr_canmove(0, dy, special, kb, ign_sv))
900 42811 y += dy;
901 else
902 {
903
2/2
✓ Branch 0 taken 16954 times.
✓ Branch 1 taken 2030 times.
18984 if(earlyret) return false;
904 2030 ret = false;
905 2030 int ysign = dy.sign();
906
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 2030 times.
2058 while(scr_canmove(0, ysign, special, kb, ign_sv))
907 {
908 28 y += ysign;
909 28 dy -= ysign;
910 }
911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2030 times.
2030 if(dy)
912 {
913 2030 dy.doDecBound(0,-9999, 0,9999);
914
3/6
✓ Branch 0 taken 2030 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2030 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2030 times.
✗ Branch 5 not taken.
31294 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
915
2/2
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 28448 times.
29264 if(scr_canmove(0, val, special, kb, ign_sv))
916 {
917 816 retval = val;
918 816 return BSEARCH_CONTINUE_AWAY0;
919 }
920 28448 else return BSEARCH_CONTINUE_TOWARD0;
921 29264 });
922 2030 y += dy;
923 2030 }
924 }
925 44841 }
926 78724 return ret;
927 113155 }
928
929 51123 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
930 {
931
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 51115 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
51123 static const zfix diagrate = zslongToFix(7071);
932
7/13
✓ Branch 0 taken 51123 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51123 times.
✓ Branch 4 taken 13029 times.
✓ Branch 5 taken 11932 times.
✓ Branch 6 taken 13226 times.
✓ Branch 7 taken 12792 times.
✓ Branch 8 taken 144 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
51123 switch(NORMAL_DIR(dir))
933 {
934 case up:
935 13029 return movexy(0, -px, special, kb, false, earlyret);
936 case down:
937 11932 return movexy(0, px, special, kb, false, earlyret);
938 case left:
939 13226 return movexy(-px, 0, special, kb, false, earlyret);
940 case right:
941 12792 return movexy(px, 0, special, kb, false, earlyret);
942 case r_up:
943 144 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
944 case r_down:
945 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
946 case l_up:
947 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
948 case l_down:
949 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
950 }
951 return false;
952 51123 }
953
954 9517 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
955 {
956 9517 double v = degrees.getFloat() * PI / 180.0;
957 9517 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
958 9517 return movexy(dx, dy, special, kb, false, earlyret);
959 }
960
961 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
962 {
963 zfix tx = x, ty = y;
964 bool ret = movexy(dx, dy, special, kb, false, true);
965 x = tx;
966 y = ty;
967 return ret;
968 }
969 39290 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
970 {
971 39290 zfix tx = x, ty = y;
972 39290 bool ret = moveDir(dir, px, special, kb, true);
973 39290 x = tx;
974 39290 y = ty;
975 39290 return ret;
976 }
977 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
978 {
979 zfix tx = x, ty = y;
980 bool ret = moveAtAngle(degrees, px, special, kb, true);
981 x = tx;
982 y = ty;
983 return ret;
984 }
985
986 // Handle pitfalls
987 39027235 bool enemy::do_falling(int32_t index)
988 {
989
2/2
✓ Branch 0 taken 39024016 times.
✓ Branch 1 taken 3219 times.
39027235 if(fallclk > 0)
990 {
991
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 3173 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 32 times.
3219 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x));
992
2/2
✓ Branch 0 taken 3173 times.
✓ Branch 1 taken 46 times.
3219 if(!--fallclk)
993 {
994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(immortal) //Keep alive forever
995 ++fallclk; //force another frame of falling.... forever.
996
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 23 times.
46 else if(dying) //Give 1 frame for script revival
997 {
998
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(flags&guy_never_return)
999 never_return(screen_spawned, index);
1000
1001
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(leader)
1002 kill_em_all();
1003
1004 //leave_item(); //Don't drop items in pits!
1005 23 stop_bgsfx(index);
1006 23 return true;
1007 }
1008 else
1009 {
1010 23 try_death(true); //Force death
1011 23 ++fallclk; //force another frame of falling
1012 }
1013 23 }
1014
1015 3196 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1016 3196 cs = spr.csets & 0xF;
1017
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 int32_t fr = spr.frames ? spr.frames : 1;
1018
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 int32_t spd = spr.speed ? spr.speed : 1;
1019 3196 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1020
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 1700 times.
3196 tile = spr.tile + zc_min(animclk / spd, fr-1);
1021 3196 }
1022 39027212 return false;
1023 39027235 }
1024
1025 // Handle drowning in water
1026 39024016 bool enemy::do_drowning(int32_t index)
1027 {
1028
2/2
✓ Branch 0 taken 39022607 times.
✓ Branch 1 taken 1409 times.
39024016 if(drownclk > 0)
1029 {
1030 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x));
1031 //!TODO: Drown SFX
1032
2/2
✓ Branch 0 taken 1367 times.
✓ Branch 1 taken 42 times.
1409 if(!--drownclk)
1033 {
1034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(immortal) //Keep alive forever
1035 ++drownclk; //force another frame of falling.... forever.
1036
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 21 times.
42 else if(dying) //Give 1 frame for script revival
1037 {
1038
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(flags&guy_never_return)
1039 never_return(screen_spawned, index);
1040
1041
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(leader)
1042 kill_em_all();
1043
1044 //leave_item(); //Don't drop items in pits!
1045 21 stop_bgsfx(index);
1046 21 return true;
1047 }
1048 else
1049 {
1050 21 try_death(true); //Force death
1051 21 ++drownclk; //force another frame of falling
1052 }
1053 21 }
1054
1055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1388 times.
1388 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1056 1388 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1057 1388 cs = spr.csets & 0xF;
1058
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 int32_t fr = spr.frames ? spr.frames : 1;
1059
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 int32_t spd = spr.speed ? spr.speed : 1;
1060 1388 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1061
2/2
✓ Branch 0 taken 1177 times.
✓ Branch 1 taken 211 times.
1388 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1062 1388 }
1063 39023995 return false;
1064 39024016 }
1065
1066 // Supplemental animation code that all derived classes should call
1067 // as a return value for animate().
1068 // Handles the death animation and returns true when enemy is finished.
1069 39714025 bool enemy::Dead(int32_t index)
1070 {
1071
2/2
✓ Branch 0 taken 29981 times.
✓ Branch 1 taken 39684044 times.
39714025 if(immortal)
1072 {
1073 29981 dying = false;
1074 29981 return false;
1075 }
1076
2/2
✓ Branch 0 taken 794520 times.
✓ Branch 1 taken 38889524 times.
39684044 if(dying)
1077 {
1078
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 794519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
794520 if(deathexstate > -1 && deathexstate < 32)
1079 {
1080 1 setxmapflag(screen_spawned, 1<<deathexstate);
1081 1 deathexstate = -1;
1082 1 }
1083 794520 --clk2;
1084
1085
4/4
✓ Branch 0 taken 725657 times.
✓ Branch 1 taken 68863 times.
✓ Branch 2 taken 38736 times.
✓ Branch 3 taken 3242 times.
794520 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1086
2/2
✓ Branch 0 taken 41978 times.
✓ Branch 1 taken 683679 times.
725657 && hp>-1000) // not killed by ringleader
1087 38736 death_sfx();
1088
1089
2/2
✓ Branch 0 taken 749620 times.
✓ Branch 1 taken 44900 times.
794520 if(clk2==0)
1090 {
1091
2/2
✓ Branch 0 taken 44196 times.
✓ Branch 1 taken 704 times.
44900 if(flags&guy_never_return)
1092 704 never_return(screen_spawned, index);
1093
1094
2/2
✓ Branch 0 taken 44822 times.
✓ Branch 1 taken 78 times.
44900 if(leader)
1095 78 kill_em_all();
1096
1097 44900 leave_item();
1098 44900 }
1099
1100 794520 stop_bgsfx(index);
1101 794520 return (clk2==0);
1102 }
1103
1104 38889524 return false;
1105 39714025 }
1106
1107 // Basic animation code that all derived classes should call.
1108 // The one with an index is the one that is called by
1109 // the guys sprite list; index is the enemy's index in the list.
1110 39027491 bool enemy::animate(int32_t index)
1111 {
1112 39027491 update_current_screen();
1113
2/2
✓ Branch 0 taken 1785810 times.
✓ Branch 1 taken 37241681 times.
39027491 if(sclk <= 0) hitdir = -1;
1114
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 39027235 times.
39027491 if(switch_hooked)
1115 {
1116
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1117 {
1118 //Run its script
1119 if (!didScriptThisFrame)
1120 {
1121 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1122 {
1123 return 0; //Avoid NULLPO if this object deleted itself
1124 }
1125 }
1126 }
1127 256 return false;
1128 }
1129
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 39027212 times.
39027235 if(do_falling(index)) return true;
1130
2/2
✓ Branch 0 taken 3196 times.
✓ Branch 1 taken 39024016 times.
39027212 else if(fallclk)
1131 {
1132 //clks
1133
2/2
✓ Branch 0 taken 2275 times.
✓ Branch 1 taken 921 times.
3196 if(hclk>0)
1134 921 --hclk;
1135
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 if(stunclk>0)
1136 --stunclk;
1137
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 if ( frozenclock > 0 )
1138 --frozenclock;
1139
1/2
✓ Branch 0 taken 3196 times.
✗ Branch 1 not taken.
3196 if(hashero)
1140 {
1141 Hero.setX(x);
1142 Hero.setY(y);
1143 Hero.fallCombo = fallCombo;
1144 Hero.fallclk = fallclk;
1145
1146 if(hashero)
1147 {
1148 hashero = false; //Let Hero go if falling
1149 Hero.setEaten(0);
1150 }
1151 }
1152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3196 times.
3196 if (!didScriptThisFrame)
1153 {
1154 3196 run_script(MODE_NORMAL);
1155 3196 }
1156 3196 return false;
1157 }
1158
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 39023995 times.
39024016 if(do_drowning(index)) return true;
1159
2/2
✓ Branch 0 taken 1388 times.
✓ Branch 1 taken 39022607 times.
39023995 else if(drownclk)
1160 {
1161 //clks
1162
2/2
✓ Branch 0 taken 853 times.
✓ Branch 1 taken 535 times.
1388 if(hclk>0)
1163 535 --hclk;
1164
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 if(stunclk>0)
1165 --stunclk;
1166
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 if ( frozenclock > 0 )
1167 --frozenclock;
1168
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 if(hashero)
1169 {
1170 Hero.setX(x);
1171 Hero.setY(y);
1172 Hero.drownclk = drownclk;
1173
1174 if(hashero)
1175 {
1176 hashero = false; //Let Hero go if falling
1177 Hero.setEaten(0);
1178 }
1179 }
1180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1388 times.
1388 if (!didScriptThisFrame)
1181 {
1182 1388 run_script(MODE_NORMAL);
1183 1388 }
1184 1388 return false;
1185 }
1186 39022607 int32_t nx = real_x(x);
1187 39022607 int32_t ny = real_y(y);
1188
1189
4/4
✓ Branch 0 taken 28201979 times.
✓ Branch 1 taken 10820628 times.
✓ Branch 2 taken 5865377 times.
✓ Branch 3 taken 22336602 times.
39022607 if(ox!=nx || oy!=ny)
1190 {
1191 16686005 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1192 16686005 }
1193
1194 39022607 ox = nx;
1195 39022607 oy = ny;
1196
1197 // Maybe they fell off the bottom in sideview, or were moved by a script.
1198
1199 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1200
2/2
✓ Branch 0 taken 29986 times.
✓ Branch 1 taken 38992621 times.
39022607 if ( immortal )
1201 {
1202 //skip, as it can go out of bounds, from immortality
1203 29986 }
1204
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38992621 times.
✓ Branch 2 taken 38992621 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38992621 times.
38992621 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1205 {
1206 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1207 }
1208
2/2
✓ Branch 0 taken 38961005 times.
✓ Branch 1 taken 31616 times.
38992621 else if (OUTOFBOUNDS(id, x, y))
1209 {
1210 31616 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1211 31616 }
1212 //fall down
1213 39022607 handle_termv();
1214
6/6
✓ Branch 0 taken 27570660 times.
✓ Branch 1 taken 11451947 times.
✓ Branch 2 taken 11181564 times.
✓ Branch 3 taken 27841043 times.
✓ Branch 4 taken 518775 times.
✓ Branch 5 taken 10662789 times.
39022607 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1215 {
1216
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 10275091 times.
10662789 if(isSideViewGravity())
1217 {
1218
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1219 {
1220
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1221 {
1222 157378 bool willHitSVPlatform = false;
1223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1225
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1226 {
1227
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1228 {
1229 willHitSVPlatform = true;
1230 break;
1231 }
1232 157378 }
1233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1234 {
1235 y+=fall/100;
1236 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1237 do_fix(y, 16); //Fix to top of SV Ladder
1238 fall = 0;
1239 }
1240 else
1241 {
1242 157378 y+=fall/100;
1243
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= get_terminalv_fall())
1244 139566 fall += get_grav_fall();
1245 }
1246 157378 }
1247 else
1248 {
1249
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1250 {
1251 //y-=(int32_t)y%8; // Fix position
1252 277 do_fix(y, 8); //Fix position
1253 277 }
1254
1255 230320 fall = 0;
1256 }
1257 387698 }
1258 else
1259 {
1260 if(isOnSideviewPlatform())
1261 fall = 0;
1262 else
1263 {
1264 zfix fall_amnt = fall/100;
1265 bool hit = false;
1266 while(fall_amnt >= 1)
1267 {
1268 --fall_amnt;
1269 ++y;
1270 if(isOnSideviewPlatform())
1271 {
1272 y = y.getInt();
1273 fall_amnt = 0;
1274 hit = true;
1275 break;
1276 }
1277 }
1278 if(fall_amnt > 0)
1279 y += fall_amnt;
1280 if(fall_amnt < 0)
1281 {
1282 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1283 hit = true;
1284 }
1285 if(hit)
1286 fall = 0;
1287 else if(fall <= get_terminalv_fall())
1288 fall += get_grav_fall();
1289 }
1290 }
1291 387698 }
1292 else
1293 {
1294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10275091 times.
10275091 if (!(moveflags & move_no_fake_z))
1295 {
1296
2/2
✓ Branch 0 taken 5707028 times.
✓ Branch 1 taken 4568063 times.
10275091 if(fakefall!=0)
1297 4568063 fakez-=(fakefall/100);
1298
1299
2/2
✓ Branch 0 taken 4568063 times.
✓ Branch 1 taken 5707028 times.
10275091 if(fakez<0)
1300 4568063 fakez = fakefall = 0;
1301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5707028 times.
5707028 else if(fakefall <= get_terminalv_fall())
1302 5707028 fakefall += get_grav_fall();
1303
1304
5/6
✓ Branch 0 taken 10275091 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5707028 times.
✓ Branch 3 taken 4568063 times.
✓ Branch 4 taken 4582310 times.
✓ Branch 5 taken 1124718 times.
10275091 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1305 10275091 }
1306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10275091 times.
10275091 if (!(moveflags & move_no_real_z))
1307 {
1308
2/2
✓ Branch 0 taken 6129417 times.
✓ Branch 1 taken 4145674 times.
10275091 if(fall!=0)
1309 4145674 z-=(fall/100);
1310
1311
2/2
✓ Branch 0 taken 4120761 times.
✓ Branch 1 taken 6154330 times.
10275091 if(z<0)
1312 4120761 z = fall = 0;
1313
2/2
✓ Branch 0 taken 16075 times.
✓ Branch 1 taken 6138255 times.
6154330 else if(fall <= get_terminalv_fall())
1314 6138255 fall += get_grav_fall();
1315
1316
6/6
✓ Branch 0 taken 10222435 times.
✓ Branch 1 taken 52656 times.
✓ Branch 2 taken 6101674 times.
✓ Branch 3 taken 4120761 times.
✓ Branch 4 taken 4990689 times.
✓ Branch 5 taken 1110985 times.
10275091 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1317 10275091 }
1318
1319 }
1320 10662789 }
1321 39022607 handle_termv();
1322
10/10
✓ Branch 0 taken 30760564 times.
✓ Branch 1 taken 8262043 times.
✓ Branch 2 taken 29433125 times.
✓ Branch 3 taken 1327439 times.
✓ Branch 4 taken 29294316 times.
✓ Branch 5 taken 138809 times.
✓ Branch 6 taken 4329044 times.
✓ Branch 7 taken 26431520 times.
✓ Branch 8 taken 19103256 times.
✓ Branch 9 taken 23432300 times.
39022607 if (can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1323 {
1324
4/4
✓ Branch 0 taken 23016776 times.
✓ Branch 1 taken 415524 times.
✓ Branch 2 taken 13153465 times.
✓ Branch 3 taken 9863311 times.
23432300 if (!isSideViewGravity() && (moveflags & move_can_pitfall))
1325 9863311 fallCombo = check_pits();
1326
4/4
✓ Branch 0 taken 415524 times.
✓ Branch 1 taken 23016776 times.
✓ Branch 2 taken 659954 times.
✓ Branch 3 taken 22356822 times.
23432300 if (!(isSideViewGravity() && get_qr(qr_OLD_SPRITE_FALL_DROWN)) && (moveflags & move_can_waterdrown))
1327 659954 drownCombo = check_water();
1328 23432300 }
1329
1330 77229119 runKnockback(); //scripted knockback handling
1331
1332 // clk is incremented here
1333
2/2
✓ Branch 0 taken 74869461 times.
✓ Branch 1 taken 2359658 times.
77229119 if(++clk >= frate)
1334 2359658 clk=0;
1335
1336 // hit and death handling
1337
2/2
✓ Branch 0 taken 1324357 times.
✓ Branch 1 taken 75904762 times.
77229119 if(hclk>0)
1338 1324357 --hclk;
1339
1340
2/2
✓ Branch 0 taken 684748 times.
✓ Branch 1 taken 76544371 times.
77229119 if(stunclk>0)
1341 684748 --stunclk;
1342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77229119 times.
77229119 if ( frozenclock > 0 )
1343 --frozenclock;
1344
1345
5/6
✓ Branch 0 taken 22710 times.
✓ Branch 1 taken 77206409 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 22521 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 189 times.
77229119 if(ceiling && z <= 0 && fakez <= 0)
1346 189 ceiling = false;
1347
1348 77229119 try_death();
1349
1350 77229119 scored=false;
1351
1352 77229119 ++c_clk;
1353
1354 //Run its script
1355
2/2
✓ Branch 0 taken 38252937 times.
✓ Branch 1 taken 38976182 times.
77229119 if (!didScriptThisFrame)
1356 {
1357
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 38976176 times.
38976182 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1358 {
1359 6 return 0; //Avoid NULLPO if this object deleted itself
1360 }
1361 38976176 }
1362
1363 // returns true when enemy is defeated
1364 77229113 return Dead(index);
1365 77234003 }
1366
1367 39799703 bool enemy::setSolid(bool set)
1368 {
1369
1/2
✓ Branch 0 taken 39799703 times.
✗ Branch 1 not taken.
39799703 bool actual = set && !isSubmerged();
1370 39799703 bool ret = solid_object::setSolid(actual);
1371 39799703 solid = set;
1372 39799703 return ret;
1373 }
1374 void enemy::doContactDamage(int32_t hdir)
1375 {
1376 Hero.hithero(guys.find(this), hdir);
1377 }
1378
1379 29704 void enemy::solid_push(solid_object *obj)
1380 {
1381
1/2
✓ Branch 0 taken 29704 times.
✗ Branch 1 not taken.
29704 if(obj == this) return; //can't push self
1382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29704 times.
29704 if(moveflags&move_not_pushable) return; //not pushable
1383 29704 zfix dx, dy;
1384 29704 int32_t hdir = -1;
1385 29704 solid_push_int(obj,dx,dy,hdir,true);
1386
1387
4/4
✓ Branch 0 taken 29591 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 336 times.
✓ Branch 3 taken 29255 times.
29704 if(!dx && !dy) return;
1388
1389 449 bool t = obj->getTempNonsolid();
1390 449 obj->setTempNonsolid(true);
1391
1392 449 int32_t ydir = dy > 0 ? down : up;
1393 449 int32_t xdir = dx > 0 ? right : left;
1394
1395 449 auto special = isflier(id) ? spw_floater : spw_none;
1396
2/2
✓ Branch 0 taken 397 times.
✓ Branch 1 taken 52 times.
449 if(!movexy(dx,dy,special,true,true))
1397 {
1398 //Crushed?
1399 52 }
1400
1401 449 obj->setTempNonsolid(t);
1402 29704 }
1403 29704 bool enemy::is_unpushable() const
1404 {
1405 29704 return isSubmerged();
1406 }
1407 29163 bool enemy::sideview_mode() const
1408 {
1409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29163 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29163 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1410 }
1411
1412 3236 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1413 {
1414 3236 int32_t yg = (special==spw_floater)?8:0;
1415 3236 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1416
1417
8/10
✓ Branch 0 taken 2366 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2370 times.
✓ Branch 9 taken 3240 times.
3236 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1418 4736 return true;
1419
1420 3240 bool isInDungeon = isdungeon(screen_spawned);
1421
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2978 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3240 if(isInDungeon || special==spw_wizzrobe)
1422 {
1423
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2377 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2978 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1424 1199 return true;
1425
1426
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1427
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1428 return true;
1429 595 }
1430
1431
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1432 {
1433
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1434
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1435 return true;
1436 62 }
1437
1438
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1439 {
1440 case spw_clipbottomright:
1441 if(dy>=128 || dx>=208) return true;
1442 break;
1443 case spw_clipright:
1444 break; //if(x>=208) return true; break;
1445
1446 case spw_wizzrobe: // fall through
1447 case spw_floater: // Special case for fliers and wizzrobes - hack!
1448 {
1449
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1450 {
1451
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1452
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1453 595 }
1454 857 return false;
1455 }
1456 }
1457
1458 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1459 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1460
1461 if(special==spw_water)
1462 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1463
1464 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1465 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1466 870 }
1467
1468 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1469 {
1470 6575 bool kb = false;
1471 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1472
1473
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1474 return true;
1475
1476
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon(screen_spawned))
1477 {
1478
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1479 return true;
1480
1481
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1482 return true;
1483 1513 }
1484
1485
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1486 {
1487
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1488
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1489 return true;
1490 6575 }
1491
1492
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1493 {
1494
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1496 }
1497 else
1498 {
1499
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1500
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1501
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1503 }
1504 6575 }
1505
1506 // returns true if cannot walk
1507 32942792 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1508 {
1509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32942792 times.
32942792 if(moveflags & move_new_movement)
1510 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1511 32942792 int32_t yg = (special==spw_floater)?8:0;
1512 32942792 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1513
2/2
✓ Branch 0 taken 3888710 times.
✓ Branch 1 taken 29054082 times.
32942792 switch(dir)
1514 {
1515 case l_down:
1516 case r_down:
1517 case down:
1518 case 11: //r_down
1519 case 12: //down
1520 case 13: //l_down
1521 {
1522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3888710 times.
3888710 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1523 {
1524
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3888702 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3888710 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1525 {
1526 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1527
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1528 8 }
1529 3888710 }
1530 3888710 break;
1531 }
1532 }
1533
2/2
✓ Branch 0 taken 3876995 times.
✓ Branch 1 taken 29065797 times.
32942792 switch(dir)
1534 {
1535 case r_up:
1536 case r_down:
1537 case right:
1538 case 9: //r_up
1539 case 10: //right
1540 case 11: //r_down
1541 {
1542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3876995 times.
3876995 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1543 {
1544
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 3876950 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
3876995 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1545 {
1546 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1547
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 dx += zc_max(hit_width-16,0);
1548 45 }
1549 3876995 }
1550 3876995 break;
1551 }
1552 }
1553
1554
10/10
✓ Branch 0 taken 22398333 times.
✓ Branch 1 taken 10544459 times.
✓ Branch 2 taken 8940039 times.
✓ Branch 3 taken 1604420 times.
✓ Branch 4 taken 10505543 times.
✓ Branch 5 taken 38916 times.
✓ Branch 6 taken 10481553 times.
✓ Branch 7 taken 23990 times.
✓ Branch 8 taken 22453602 times.
✓ Branch 9 taken 32935155 times.
32942792 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1555 44914841 return true;
1556
1557 32935155 bool isInDungeon = isdungeon(screen_spawned);
1558
4/4
✓ Branch 0 taken 4413396 times.
✓ Branch 1 taken 28521759 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 4401640 times.
32935155 if(isInDungeon || special==spw_wizzrobe)
1559 {
1560
8/8
✓ Branch 0 taken 5892236 times.
✓ Branch 1 taken 22641279 times.
✓ Branch 2 taken 5667745 times.
✓ Branch 3 taken 224491 times.
✓ Branch 4 taken 5820349 times.
✓ Branch 5 taken 17045421 times.
✓ Branch 6 taken 5820162 times.
✓ Branch 7 taken 187 times.
28533515 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1561 11487907 return true;
1562
1563
8/8
✓ Branch 0 taken 5739852 times.
✓ Branch 1 taken 11305756 times.
✓ Branch 2 taken 5573332 times.
✓ Branch 3 taken 166520 times.
✓ Branch 4 taken 5688285 times.
✓ Branch 5 taken 5783991 times.
✓ Branch 6 taken 5687331 times.
✓ Branch 7 taken 954 times.
17045608 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1564
2/2
✓ Branch 0 taken 113905 times.
✓ Branch 1 taken 94 times.
11260663 if(special!=spw_door) // walk in door way
1565 113905 return true;
1566 5785039 }
1567
1568
6/6
✓ Branch 0 taken 3260136 times.
✓ Branch 1 taken 6926543 times.
✓ Branch 2 taken 907960 times.
✓ Branch 3 taken 2352176 times.
✓ Branch 4 taken 61002 times.
✓ Branch 5 taken 846958 times.
10186679 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1569 {
1570
4/4
✓ Branch 0 taken 3191204 times.
✓ Branch 1 taken 7930 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 3190205 times.
6389416 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1571
4/4
✓ Branch 0 taken 3191005 times.
✓ Branch 1 taken 199 times.
✓ Branch 2 taken 3190282 times.
✓ Branch 3 taken 723 times.
3191204 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1572 8929 return true;
1573 3190205 }
1574
1575
4/4
✓ Branch 0 taken 7810305 times.
✓ Branch 1 taken 2360740 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5732 times.
10177750 switch(special)
1576 {
1577 case spw_clipbottomright:
1578
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1579 707 break;
1580 case spw_clipright:
1581 5732 break; //if(input_x>=208) return true; break;
1582
1583 case spw_wizzrobe: // fall through
1584 case spw_floater: // Special case for fliers and wizzrobes - hack!
1585 {
1586
2/2
✓ Branch 0 taken 3168626 times.
✓ Branch 1 taken 4641679 times.
7810305 if(isInDungeon)
1587 {
1588
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= world_h-32) return true;
1589
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= world_w-32) return true;
1590 4639539 }
1591 7808165 return false;
1592 }
1593 }
1594
1595 2367179 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1596
2/2
✓ Branch 0 taken 564791 times.
✓ Branch 1 taken 1802388 times.
2367179 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1597
1598
2/2
✓ Branch 0 taken 439102 times.
✓ Branch 1 taken 1928077 times.
2367179 if(special==spw_water)
1599
2/2
✓ Branch 0 taken 17784 times.
✓ Branch 1 taken 421318 times.
439102 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1600
1601
2/2
✓ Branch 0 taken 1711908 times.
✓ Branch 1 taken 216169 times.
1928077 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1602 {
1603
4/4
✓ Branch 0 taken 1228217 times.
✓ Branch 1 taken 483691 times.
✓ Branch 2 taken 1218180 times.
✓ Branch 3 taken 10037 times.
2930088 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1604
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203600 times.
1218180 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1605 }
1606 else
1607 {
1608
4/4
✓ Branch 0 taken 164129 times.
✓ Branch 1 taken 52040 times.
✓ Branch 2 taken 163777 times.
✓ Branch 3 taken 352 times.
379946 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1609
4/4
✓ Branch 0 taken 162854 times.
✓ Branch 1 taken 923 times.
✓ Branch 2 taken 162838 times.
✓ Branch 3 taken 16 times.
163777 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1610
4/4
✓ Branch 0 taken 152476 times.
✓ Branch 1 taken 10362 times.
✓ Branch 2 taken 152461 times.
✓ Branch 3 taken 15 times.
162838 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1611
2/2
✓ Branch 0 taken 152158 times.
✓ Branch 1 taken 303 times.
152461 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1612 }
1613 10571176 }
1614
1615 496901 bool enemy::isOnSideviewPlatform()
1616 {
1617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1619
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1620 return false;
1621
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1623
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1624 {
1625
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1626
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1628 64328 }
1629 215641 return false;
1630 496901 }
1631
1632 // Stops playing the given sound only if there are no enemies left to play it
1633 797515 void enemy::stop_bgsfx(int32_t index)
1634 {
1635
2/2
✓ Branch 0 taken 781312 times.
✓ Branch 1 taken 16203 times.
797515 if(bgsfx<=0)
1636 781312 return;
1637
1638 // Look for other enemies with the same bgsfx
1639
2/2
✓ Branch 0 taken 55203 times.
✓ Branch 1 taken 9313 times.
64516 for(int32_t i=0; i<guys.Count(); i++)
1640 {
1641
4/4
✓ Branch 0 taken 43166 times.
✓ Branch 1 taken 12037 times.
✓ Branch 2 taken 6890 times.
✓ Branch 3 taken 36276 times.
55203 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1642 6890 return;
1643 48313 }
1644
1645 9313 stop_sfx(bgsfx);
1646 797515 }
1647
1648
1649 // to allow for different sfx on defeating enemy
1650 41726 void enemy::death_sfx()
1651 {
1652
2/2
✓ Branch 0 taken 41441 times.
✓ Branch 1 taken 285 times.
41726 if(deadsfx > 0) sfx(deadsfx,pan(x));
1653 41726 }
1654
1655 void enemy::move(zfix dx,zfix dy)
1656 {
1657 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1658 {
1659 x+=dx;
1660 y+=dy;
1661 }
1662 }
1663
1664 19033497 void enemy::move(zfix s)
1665 {
1666
9/10
✓ Branch 0 taken 19033458 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18924349 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
19033497 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1667 {
1668 19032453 sprite::move(s);
1669 19032453 }
1670 19033497 }
1671
1672 45202 void enemy::leave_item()
1673 {
1674 45202 int32_t drop_item = select_dropitem(item_set, x, y);
1675 45202 int32_t thedropset = item_set;
1676
1677 45202 std::vector<int32_t> &ev = FFCore.eventData;
1678 45202 ev.clear();
1679 45202 ev.push_back(getUID());
1680 45202 ev.push_back(drop_item*10000);
1681 45202 ev.push_back(thedropset*10000);
1682
1683 45202 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1684 45202 drop_item = vbound(ev[1] / 10000,-2,255);
1685 45202 thedropset = ev[2] / 10000;
1686 45202 ev.clear();
1687
1/2
✓ Branch 0 taken 45202 times.
✗ Branch 1 not taken.
45202 if(drop_item == -2)
1688 {
1689 drop_item = select_dropitem(thedropset,x,y);
1690 }
1691
1692
6/6
✓ Branch 0 taken 17094 times.
✓ Branch 1 taken 28108 times.
✓ Branch 2 taken 921 times.
✓ Branch 3 taken 16173 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 752 times.
45202 if(drop_item>=0&&((itemsbuf[drop_item].type!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1693 {
1694 item* itm;
1695
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 16376 times.
16925 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1696 {
1697
10/20
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 549 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 549 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 549 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 549 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 549 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 549 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 549 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 549 times.
✗ Branch 19 not taken.
549 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1698 549 }
1699 else
1700 {
1701
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14656 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16376 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1702
4/8
✓ Branch 0 taken 14656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14656 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14656 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14656 times.
✗ Branch 7 not taken.
14656 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1703 }
1704 16925 itm->from_dropset = thedropset;
1705 16925 add_item_for_screen(screen_spawned, itm);
1706
1707 16925 ev.push_back(getUID());
1708 16925 ev.push_back(itm->getUID());
1709
1710 16925 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1711 16925 ev.clear();
1712 16925 }
1713 45202 }
1714
1715 // auomatically kill off enemy (for rooms with ringleaders)
1716 419 void enemy::kickbucket()
1717 {
1718
3/4
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 387 times.
✗ Branch 3 not taken.
419 if(!superman && !(flags&guy_ignore_kill_all))
1719 387 hp=-1000; // don't call death_sfx()
1720 419 }
1721
1722 27212 bool enemy::isSubmerged() const
1723 {
1724 27212 return submerged;
1725 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1726 }
1727
1728 20952 void enemy::FireBreath(bool seekhero)
1729 {
1730
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1731 return;
1732
1733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1734 {
1735 dmisc1 = e1tEACHTILE;
1736 FireWeapon();
1737 return;
1738 }
1739
1740 20952 float fire_angle=0.0;
1741 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1742
1743
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1744 {
1745 xoff += hxofs;
1746 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1747 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1748 else
1749 xoff += (hit_width / 2) - 8;
1750 }
1751
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1752 {
1753 yoff += hyofs;
1754 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1755 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1756 else
1757 yoff += (hit_height / 2) - 8;
1758 }
1759
1760
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1761 {
1762
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1763 {
1764 case down:
1765 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1766 3079 wx=x;
1767 3079 wy=y+8;
1768 3079 break;
1769
1770 case -1:
1771 case up:
1772 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1773 3297 wx=x;
1774 3297 wy=y-8;
1775 3297 break;
1776
1777 case left:
1778 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1779 5287 wx=x-8;
1780 5287 wy=y;
1781 5287 break;
1782
1783 case right:
1784 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1785 4208 wx=x+8;
1786 4208 wy=y;
1787 4208 break;
1788 }
1789
1790
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1791 {
1792
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1798
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1799
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1800 15735 }
1801 15871 }
1802 else
1803 {
1804 5081 wx = x;
1805 5081 wy = y;
1806 }
1807
1808
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1809 20952 sfx(wpnsfx(wpn),pan(x));
1810
1811 20952 int32_t i=Ewpns.Count()-1;
1812 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1813 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1814
1815
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1816 {
1817 7957 ew->angular=true;
1818 7957 ew->angle=fire_angle;
1819 7957 }
1820
1821
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1822 {
1823 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1825 20359 }
1826
1827
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1828 {
1829 766199 Ewpns.swap(j,j-1);
1830 766199 }
1831 20952 }
1832
1833 45994 void enemy::FireWeapon()
1834 {
1835 /*
1836 * Type:
1837 * 0x01: Boss fireball
1838 * 0x02: Seeks Hero
1839 * 0x04: Fast projectile
1840 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1841 */
1842
1843
2/2
✓ Branch 0 taken 45863 times.
✓ Branch 1 taken 131 times.
45994 if (wpn < 1) return;
1844
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 45863 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
45863 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1845 return;
1846
1847
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45863 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
45863 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1848 dmisc1 = e1tEACHTILE;
1849
1850 45863 int32_t xoff = 0;
1851 45863 int32_t yoff = 0;
1852
1/2
✓ Branch 0 taken 45863 times.
✗ Branch 1 not taken.
45863 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1853 {
1854 xoff += hxofs;
1855 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1856 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1857 else
1858 xoff += (hit_width / 2) - 8;
1859 }
1860
1/2
✓ Branch 0 taken 45863 times.
✗ Branch 1 not taken.
45863 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1861 {
1862 yoff += hyofs;
1863 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1864 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1865 else
1866 yoff += (hit_height / 2) - 8;
1867 }
1868
1869 // TODO(crash): check that .add succeeds.
1870
1871
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 42856 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 424 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
45863 switch(dmisc1)
1872 {
1873 case e1t5SHOTS: //BS-Aquamentus
1874 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1875 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1876 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1877 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1878
1879 [[fallthrough]];
1880 case e1t3SHOTSFAST:
1881 case e1t3SHOTS: //Aquamentus
1882
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1883 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1884
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1885 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1886
1887 [[fallthrough]];
1888 default:
1889
12/20
✓ Branch 0 taken 43502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43502 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 43502 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 43502 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 43502 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 43497 times.
✓ Branch 12 taken 43502 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 25264 times.
✓ Branch 16 taken 43502 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 43502 times.
✗ Branch 19 not taken.
43502 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1890 43502 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1891 43502 sfx(wpnsfx(wpn),pan(x));
1892 43502 break;
1893
1894 case e1tSLANT:
1895 {
1896 424 int32_t slant = 0;
1897
1898
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 224 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 153 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
424 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1899 246 slant = left;
1900
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1901 117 slant = right;
1902
1903
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1904 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1905 330 sfx(wpnsfx(wpn),pan(x));
1906 330 break;
1907 }
1908
1909 case e1t8SHOTS: //Fire Wizzrobe
1910
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1911 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1912 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1913
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1914 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1915 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1916
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1917 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1918 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1919
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1920 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1921 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1922
1923 [[fallthrough]];
1924 case e1t4SHOTS: //Stalfos 3
1925
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1926 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1927 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1928
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1929 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1930 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1931
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1932 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1933 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1934
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1935 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1936 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1937 1937 sfx(wpnsfx(wpn),pan(x));
1938 1937 break;
1939
1940 case e1tSUMMON: // Bat Wizzrobe
1941 {
1942 if(dmisc4==0) break; // Summon 0
1943
1944 int32_t bc=0;
1945
1946 for(int32_t gc=0; gc<guys.Count(); gc++)
1947 {
1948 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1949 {
1950 ++bc;
1951 }
1952 }
1953
1954 if(bc<=40) // Not too many enemies
1955 {
1956 int32_t kids = guys.Count();
1957 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1958
1959 for(int32_t i=0; i<bats; i++)
1960 {
1961 if(addchild(screen_spawned,x,y,dmisc3,-10, this))
1962 {
1963 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1964 }
1965 }
1966
1967 sfx(firesfx, pan(x));
1968 }
1969
1970 break;
1971 }
1972
1973 case e1tSUMMONLAYER: // Summoner
1974 {
1975 if(count_layer_enemies(screen_spawned)==0)
1976 {
1977 break;
1978 }
1979
1980 int32_t kids = guys.Count();
1981
1982 if(kids<40)
1983 {
1984 int32_t newguys=(zc_oldrand()%3)+1;
1985 bool summoned=false;
1986
1987 for(int32_t i=0; i<newguys; i++)
1988 {
1989 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
1990 int32_t x2=0;
1991 int32_t y2=0;
1992
1993 for(int32_t k=0; k<20; ++k)
1994 {
1995 x2=16*((zc_oldrand()%12)+2);
1996 y2=16*((zc_oldrand()%7)+2);
1997
1998 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
1999 {
2000 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
2001 {
2002 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2003 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2004 {
2005 ((enemy*)guys.spr(kids+i))->fakez = 64;
2006 ((enemy*)guys.spr(kids+i))->z = 0;
2007 }
2008 }
2009
2010 summoned=true;
2011 break;
2012 }
2013 }
2014 }
2015
2016 if(summoned)
2017 {
2018 sfx(firesfx, pan(x));
2019 }
2020 }
2021
2022 break;
2023 }
2024 }
2025 45900 }
2026
2027
2028 // Hit the shield(s)?
2029 // Apparently, this function is only used for hookshots...
2030 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2031 {
2032
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(type==eeWALK || type==eeFIRE || type==eeOTHER))
2033 834 return false;
2034
2035 1933 bool ret = false;
2036
2037 // TODO: There must be some bitwise operations that can simplify this...
2038
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2039
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2040
2041
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2042
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2043
2044 1933 return ret;
2045 2767 }
2046
2047
2048 //! Weapon Editor for 2.6
2049 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2050
2051
2052 //converts a wqeapon ID to its defence index.
2053 136228 int32_t weaponToDefence(int32_t wid)
2054 {
2055
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 67251 times.
✓ Branch 2 taken 9439 times.
✓ Branch 3 taken 25184 times.
✓ Branch 4 taken 4409 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3334 times.
✓ Branch 9 taken 10907 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1438 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2153 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 486 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 4583 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
136228 switch(wid)
2056 {
2057 case wNone: return -1;
2058 67251 case wSword: return edefSWORD;
2059 9439 case wBeam: return edefBEAM;
2060 25184 case wBrang: return edefBRANG;
2061 4409 case wBomb: return edefBOMB;
2062 37 case wSBomb: return edefSBOMB;
2063 48 case wLitBomb: return edefBOMB;
2064 case wLitSBomb: return edefSBOMB;
2065 3334 case wArrow: return edefARROW;
2066 10907 case wFire: return edefFIRE;
2067 case wWhistle:
2068 {
2069 return edefWhistle;
2070 }
2071 case wBait: return edefBAIT;
2072 269 case wWand: return edefWAND;
2073 1438 case wMagic: return edefMAGIC;
2074 case wCatching: return -1;
2075 case wWind: return edefWIND;
2076 512 case wRefMagic: return edefREFMAGIC;
2077 1459 case wRefFireball: return edefREFBALL;
2078 case wRefRock: return edefREFROCK;
2079 2153 case wHammer: return edefHAMMER;
2080 2767 case wHookshot: return edefHOOKSHOT;
2081 610 case wHSHandle: return edefHOOKSHOT;
2082 case wHSChain: return edefHOOKSHOT;
2083 240 case wSSparkle: return edefSPARKLE;
2084 486 case wFSparkle: return edefSPARKLE;
2085 case wSmack: return -1; // is this the candle object?
2086 case wPhantom: return -1; //engine created visual effects.
2087 case wCByrna: return edefBYRNA;
2088 19 case wRefBeam: return edefREFBEAM;
2089 case wStomp: return edefSTOMP;
2090 4583 case wScript1: return edefSCRIPT01;
2091 case wScript2: return edefSCRIPT02;
2092 12 case wScript3: return edefSCRIPT03;
2093 77 case wScript4: return edefSCRIPT04;
2094 case wScript5: return edefSCRIPT05;
2095 case wScript6: return edefSCRIPT06;
2096 case wScript7: return edefSCRIPT07;
2097 case wScript8: return edefSCRIPT08;
2098 case wScript9: return edefSCRIPT09;
2099 993 case wScript10: return edefSCRIPT10;
2100 case wIce: return edefICE;
2101 case wSound: return edefSONIC;
2102 1 case wThrown: return edefTHROWN;
2103 case wRefArrow: return edefREFARROW;
2104 case wRefFire: return edefREFFIRE;
2105 case wRefFire2: return edefREFFIRE2;
2106 //case wPot: return edefPOT;
2107 // case wLitZap: return edefELECTRIC;
2108 // case wZ3Sword: return edefZ3SWORD;
2109 // case wLASWord: return edefLASWORD;
2110 // case wSpinAttk: return edefSPINATTK;
2111 // case wShield: return edefSHIELD;
2112 // case wTrowel: return edefTROWEL;
2113
2114 default: return -1;
2115 }
2116 136228 }
2117
2118 136228 int32_t getDefType(weapon *w)
2119 {
2120 136228 int32_t id = getWeaponID(w);
2121 136228 int32_t edef = weaponToDefence(id);
2122
2/2
✓ Branch 0 taken 132851 times.
✓ Branch 1 taken 3377 times.
136228 if(edef == edefHOOKSHOT)
2123 {
2124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2125 return edefSwitchHook;
2126 3377 }
2127 136228 return edef;
2128 136228 }
2129
2130 244505 int32_t getWeaponID(weapon *w)
2131 {
2132 244505 int32_t usewpn = w->useweapon;
2133
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 244275 times.
244505 return (usewpn > 0) ? usewpn : w->id;
2134 }
2135
2136 136228 int32_t enemy::resolveEnemyDefence(weapon *w)
2137 {
2138 //sword edef is 9, but we're reading it at 0
2139 //,
2140 136228 int32_t weapondef = 0;
2141 136228 int32_t wdeftype = getDefType(w);
2142 136228 int32_t usedef = w->usedefense;
2143
2144
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 136228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
136228 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2145 {
2146 weapondef = usedef*-1;
2147 }
2148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136228 times.
136228 else if(unsigned(wdeftype) < edefLAST255)
2149 {
2150 136228 weapondef = wdeftype;
2151 136228 }
2152 136228 return weapondef;
2153 }
2154
2155 147104 byte get_def_ignrflag(int32_t edef)
2156 {
2157
3/3
✓ Branch 0 taken 119115 times.
✓ Branch 1 taken 3702 times.
✓ Branch 2 taken 24287 times.
147104 switch(edef)
2158 {
2159 case edIGNORE:
2160 case edIGNOREL1:
2161 case edSTUNORIGNORE:
2162 24287 return WPNUNB_IGNR;
2163 case edSTUNORCHINK:
2164 case edCHINK:
2165 case edCHINKL1:
2166 case edCHINKL2:
2167 case edCHINKL4:
2168 case edCHINKL6:
2169 case edCHINKL8:
2170 case edCHINKL10:
2171 case edLEVELCHINK2:
2172 case edLEVELCHINK3:
2173 case edLEVELCHINK4:
2174 case edLEVELCHINK5:
2175 3702 return WPNUNB_BLOCK;
2176 }
2177 119115 return 0;
2178 147104 }
2179
2180 147104 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2181 {
2182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147104 times.
147104 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2183 switch(edef)
2184 {
2185 case edIGNORE:
2186 case edIGNOREL1:
2187 case edCHINK:
2188 case edCHINKL1:
2189 case edCHINKL2:
2190 case edCHINKL4:
2191 case edCHINKL6:
2192 case edCHINKL8:
2193 case edCHINKL10:
2194 case edLEVELCHINK2:
2195 case edLEVELCHINK3:
2196 case edLEVELCHINK4:
2197 case edLEVELCHINK5:
2198 return edNORMAL;
2199 case edSTUNORIGNORE:
2200 case edSTUNORCHINK:
2201 return edSTUNONLY;
2202 }
2203 return edef;
2204 147104 }
2205
2206 // Do we do damage?
2207 // 0: takehit returns 0
2208 // 1: takehit returns 1
2209 // -1: do damage
2210 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2211 135235 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2212 {
2213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135235 times.
135235 if(switch_hooked) return 0;
2214 135235 int32_t tempx = x;
2215 135235 int32_t tempy = y;
2216 135235 int32_t the_defence = 0;
2217
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2218 {
2219 the_defence = edef*-1; //A specific defence type.
2220 }
2221 135235 else the_defence = defense[edef];
2222
2223 135235 the_defence = conv_edef_unblockable(the_defence, unblockable);
2224
2225
3/4
✓ Branch 0 taken 6811 times.
✓ Branch 1 taken 128424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6811 times.
135235 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2226 {
2227
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6804 times.
✓ Branch 2 taken 7 times.
6811 switch(the_defence)
2228 {
2229 case edIGNORE:
2230 7 return 0;
2231 case edIGNOREL1:
2232 case edSTUNORIGNORE:
2233 if(*power <= 0)
2234 return 0;
2235 }
2236 6804 sfx(WAV_CHINK,pan(x));
2237 6804 return 1;
2238 }
2239
2240 128424 int32_t new_id = id;
2241 128424 int32_t effect_type = dmisc15;
2242 128424 int32_t delay_timer = 90;
2243 128424 enemy *gleeok = NULL;
2244 128424 enemy *ptra = NULL;
2245 128424 int32_t c = 0;
2246
2247
17/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 525 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1935 times.
✓ Branch 6 taken 1958 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 963 times.
✓ Branch 13 taken 22345 times.
✓ Branch 14 taken 1007 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 497 times.
✓ Branch 23 taken 8 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 181 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 96382 times.
128424 switch(the_defence)
2248 {
2249 case edREPLACE:
2250 {
2251 sclk = 0;
2252 if ( dmisc16 > 0 ) new_id = dmisc16;
2253 else new_id = id+1;
2254 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2255 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2256 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2257
2258 //Z_scripterrlog("new id is %d\n", new_id);
2259 switch(guysbuf[new_id&0xFFF].type)
2260 {
2261 //Fixme: possible enemy memory leak. (minor)
2262 case eeWALK:
2263 {
2264 enemy *e = new eStalfos(x,y,new_id,clk);
2265 guys.add(e);
2266 }
2267 break;
2268
2269 case eeLEV:
2270 {
2271 enemy *e = new eLeever(x,y,new_id,clk);
2272 guys.add(e);
2273 }
2274 break;
2275
2276 case eeTEK:
2277 {
2278 enemy *e = new eTektite(x,y,new_id,clk);
2279 guys.add(e);
2280 }
2281 break;
2282
2283 case eePEAHAT:
2284 {
2285 enemy *e = new ePeahat(x,y,new_id,clk);
2286 guys.add(e);
2287 }
2288 break;
2289
2290 case eeZORA:
2291 {
2292 enemy *e = new eZora(x,y,new_id,clk);
2293 guys.add(e);
2294 }
2295 break;
2296
2297 case eeGHINI:
2298 {
2299 enemy *e = new eGhini(x,y,new_id,clk);
2300 guys.add(e);
2301 }
2302 break;
2303
2304 case eeKEESE:
2305 {
2306 enemy *e = new eKeese(x,y,new_id,clk);
2307 guys.add(e);
2308 }
2309 break;
2310
2311 case eeWIZZ:
2312 {
2313 enemy *e = new eWizzrobe(x,y,new_id,clk);
2314 guys.add(e);
2315 }
2316 break;
2317
2318 case eePROJECTILE:
2319 {
2320 enemy *e = new eProjectile(x,y,new_id,clk);
2321 guys.add(e);
2322 }
2323 break;
2324
2325 case eeWALLM:
2326 {
2327 enemy *e = new eWallM(x,y,new_id,clk);
2328 guys.add(e);
2329 }
2330 break;
2331
2332 case eeAQUA:
2333 {
2334 enemy *e = new eAquamentus(x,y,new_id,clk);
2335 guys.add(e);
2336 e->x = x;
2337 e->y = y;
2338 }
2339 break;
2340
2341 case eeMOLD:
2342 {
2343 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2344 guys.add(e);
2345 e->x = x;
2346 e->y = y;
2347 }
2348 break;
2349
2350 case eeMANHAN:
2351 {
2352 enemy *e = new eManhandla(x,y,new_id,clk);
2353 guys.add(e);
2354 e->x = x;
2355 e->y = y;
2356 }
2357 break;
2358
2359 case eeGLEEOK:
2360 {
2361 *power = 0;
2362 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2363 guys.add(gleeok);
2364 // TODO(crash): check that .add succeeds.
2365 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2366 new_id &= 0xFFF;
2367 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2368 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2369 for(int32_t i=0; i<head_cnt; i++)
2370 {
2371 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2372 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2373 {
2374 al_trace("Gleeok head %d could not be created!\n",i+1);
2375
2376 for(int32_t j=0; j<i+1; j++)
2377 {
2378 guys.del(guys.Count()-1);
2379 }
2380
2381 break;
2382 }
2383 else
2384 {
2385 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2386 }
2387
2388 c-=guysbuf[new_id].attributes[3];
2389 }
2390 return 1;
2391 }
2392
2393 case eeGHOMA:
2394 {
2395 enemy *e = new eGohma(x,y,new_id,clk);
2396 guys.add(e);
2397 e->x = x;
2398 e->y = y;
2399 }
2400 break;
2401
2402 case eeLANM:
2403 {
2404 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2405 guys.add(e);
2406 e->x = x;
2407 e->y = y;
2408 }
2409 break;
2410
2411 case eeGANON:
2412 {
2413 enemy *e = new eGanon(x,y,new_id,clk);
2414 guys.add(e);
2415 e->x = x;
2416 e->y = y;
2417 }
2418 break;
2419
2420 case eeFAIRY:
2421 {
2422 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2423 guys.add(e);
2424 e->x = x;
2425 e->y = y;
2426 }
2427 break;
2428
2429 case eeFIRE:
2430 {
2431 enemy *e = new eFire(x,y,new_id,clk);
2432 guys.add(e);
2433 e->x = x;
2434 e->y = y;
2435 }
2436 break;
2437
2438 case eeOTHER:
2439 {
2440 enemy *e = new eOther(x,y,new_id,clk);
2441 guys.add(e);
2442 e->x = x;
2443 e->y = y;
2444 }
2445 break;
2446
2447 case eeSPINTILE:
2448 {
2449 enemy *e = new eSpinTile(x,y,new_id,clk);
2450 guys.add(e);
2451 e->x = x;
2452 e->y = y;
2453 }
2454 break;
2455
2456 // and these enemies use the misc10/misc2 value
2457 case eeROCK:
2458 {
2459 switch(guysbuf[new_id&0xFFF].attributes[9])
2460 {
2461 case 1:
2462 {
2463 enemy *e = new eBoulder(x,y,new_id,clk);
2464 guys.add(e);
2465 e->x = x;
2466 e->y = y;
2467 }
2468 break;
2469
2470 case 0:
2471 default:
2472 {
2473 enemy *e = new eRock(x,y,new_id,clk);
2474 guys.add(e);
2475 e->x = x;
2476 e->y = y;
2477 }
2478 break;
2479 }
2480
2481 break;
2482 }
2483
2484 case eeTRAP:
2485 {
2486 switch(guysbuf[new_id&0xFFF].attributes[1])
2487 {
2488 case 1:
2489 {
2490 enemy *e = new eTrap2(x,y,new_id,clk);
2491 guys.add(e);
2492 e->x = x;
2493 e->y = y;
2494 }
2495 break;
2496
2497 case 0:
2498 default:
2499 {
2500 enemy *e = new eTrap(x,y,new_id,clk);
2501 guys.add(e);
2502 e->x = x;
2503 e->y = y;
2504 }
2505 break;
2506 }
2507
2508 break;
2509 }
2510
2511 case eeDONGO:
2512 {
2513 switch(guysbuf[new_id&0xFFF].attributes[9])
2514 {
2515 case 1:
2516 {
2517 enemy *e = new eDodongo2(x,y,new_id,clk);
2518 guys.add(e);
2519 e->x = x;
2520 e->y = y;
2521 }
2522 break;
2523
2524 case 0:
2525 default:
2526 {
2527 enemy *e = new eDodongo(x,y,new_id,clk);
2528 guys.add(e);
2529 e->x = x;
2530 e->y = y;
2531 }
2532 break;
2533 }
2534
2535 break;
2536 }
2537
2538 case eeDIG:
2539 {
2540 switch(guysbuf[new_id&0xFFF].attributes[9])
2541 {
2542 case 1:
2543 {
2544 enemy *e = new eLilDig(x,y,new_id,clk);
2545 guys.add(e);
2546 e->x = x;
2547 e->y = y;
2548 }
2549 break;
2550
2551 case 0:
2552 default:
2553 {
2554 enemy *e = new eBigDig(x,y,new_id,clk);
2555 guys.add(e);
2556 e->x = x;
2557 e->y = y;
2558 }
2559 break;
2560 }
2561
2562 break;
2563 }
2564
2565 case eePATRA:
2566 {
2567 switch(guysbuf[new_id&0xFFF].attributes[9])
2568 {
2569 case 1:
2570 {
2571 if (get_qr(qr_HARDCODED_BS_PATRA))
2572 {
2573 enemy *e = new ePatraBS(x,y,new_id,clk);
2574 guys.add(e);
2575 e->x = x;
2576 e->y = y;
2577 break;
2578 }
2579 }
2580 [[fallthrough]];
2581 case 0:
2582 default:
2583 {
2584 enemy *e = new ePatra(x,y,new_id,clk);
2585 guys.add(e);
2586 e->x = x;
2587 e->y = y;
2588 }
2589 break;
2590 }
2591
2592 break;
2593 }
2594
2595 case eeGUY:
2596 {
2597 switch(guysbuf[new_id&0xFFF].attributes[9])
2598 {
2599 case 1:
2600 {
2601 enemy *e = new eTrigger(x,y,new_id,clk);
2602 guys.add(e);
2603 }
2604 break;
2605
2606 case 0:
2607 default:
2608 {
2609 enemy *e = new eNPC(x,y,new_id,clk);
2610 guys.add(e);
2611 }
2612 break;
2613 }
2614
2615 break;
2616 }
2617
2618 case eeSCRIPT01:
2619 case eeSCRIPT02:
2620 case eeSCRIPT03:
2621 case eeSCRIPT04:
2622 case eeSCRIPT05:
2623 case eeSCRIPT06:
2624 case eeSCRIPT07:
2625 case eeSCRIPT08:
2626 case eeSCRIPT09:
2627 case eeSCRIPT10:
2628 case eeSCRIPT11:
2629 case eeSCRIPT12:
2630 case eeSCRIPT13:
2631 case eeSCRIPT14:
2632 case eeSCRIPT15:
2633 case eeSCRIPT16:
2634 case eeSCRIPT17:
2635 case eeSCRIPT18:
2636 case eeSCRIPT19:
2637 case eeSCRIPT20:
2638 {
2639 enemy *e = new eScript(x,y,new_id,clk);
2640 guys.add(e);
2641 e->x = x;
2642 e->y = y;
2643 break;
2644 }
2645
2646
2647 case eeFFRIENDLY01:
2648 case eeFFRIENDLY02:
2649 case eeFFRIENDLY03:
2650 case eeFFRIENDLY04:
2651 case eeFFRIENDLY05:
2652 case eeFFRIENDLY06:
2653 case eeFFRIENDLY07:
2654 case eeFFRIENDLY08:
2655 case eeFFRIENDLY09:
2656 case eeFFRIENDLY10:
2657 {
2658 enemy *e = new eFriendly(x,y,new_id,clk);
2659 guys.add(e);
2660 e->x = x;
2661 e->y = y;
2662 break;
2663 }
2664
2665
2666 default: break;
2667 }
2668
2669 // add segments of segmented enemies
2670 int32_t c=0;
2671
2672 switch(guysbuf[new_id&0xFFF].type)
2673 {
2674 case eeMOLD:
2675 {
2676 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2677 new_id &= 0xFFF;
2678
2679 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2680 {
2681 //christ this is messy -DD
2682 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2683
2684 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2685 {
2686 al_trace("Moldorm segment %d could not be created!\n",i+1);
2687
2688 for(int32_t j=0; j<i+1; j++)
2689 guys.del(guys.Count()-1);
2690
2691 return 0;
2692 }
2693
2694 if(i>0)
2695 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2696
2697
2698 }
2699
2700 break;
2701 }
2702
2703 case eeLANM:
2704 {
2705 new_id &= 0xFFF;
2706 int32_t shft = guysbuf[new_id].attributes[1];
2707 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2708 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2709
2710 if(!guys.add(e))
2711 {
2712 al_trace("Lanmola segment 1 could not be created!\n");
2713 guys.del(guys.Count()-1);
2714 return 0;
2715 }
2716 e->x = x;
2717 e->y = y;
2718
2719
2720
2721 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2722 {
2723 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2724 if(!guys.add(e2))
2725 {
2726 al_trace("Lanmola segment %d could not be created!\n",i+1);
2727
2728 for(int32_t j=0; j<i+1; j++)
2729 guys.del(guys.Count()-1);
2730
2731 return 0;
2732 }
2733 e2->x = x;
2734 e2->y = y;
2735
2736 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2737
2738 }
2739 }
2740 break;
2741
2742 case eeMANHAN:
2743 new_id &= 0xFFF;
2744
2745 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2746 {
2747 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2748 {
2749 al_trace("Manhandla head %d could not be created!\n",i+1);
2750
2751 for(int32_t j=0; j<i+1; j++)
2752 {
2753 guys.del(guys.Count()-1);
2754 }
2755
2756 return 0;
2757 }
2758
2759
2760 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2761 }
2762
2763 break;
2764
2765 case eeGLEEOK:
2766 {
2767 /*
2768 new_id &= 0xFFF;
2769 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2770 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2771 for(int32_t i=0; i<head_cnt; i++)
2772 {
2773 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2774 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2775 {
2776 al_trace("Gleeok head %d could not be created!\n",i+1);
2777
2778 for(int32_t j=0; j<i+1; j++)
2779 {
2780 guys.del(guys.Count()-1);
2781 }
2782
2783 break;
2784 }
2785
2786 c-=guysbuf[new_id].misc4;
2787 */
2788
2789 // }
2790 }
2791 break;
2792
2793
2794 case eePATRA:
2795 {
2796 new_id &= 0xFFF;
2797 int32_t outeyes = 0;
2798 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2799
2800 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2801 {
2802 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2803 {
2804 al_trace("Patra outer eye %d could not be created!\n",i+1);
2805
2806 for(int32_t j=0; j<i+1; j++)
2807 guys.del(guys.Count()-1);
2808
2809 return 0;
2810 }
2811 else
2812 outeyes++;
2813
2814
2815 }
2816
2817 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2818 {
2819 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2820 {
2821 al_trace("Patra inner eye %d could not be created!\n",i+1);
2822
2823 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2824 guys.del(guys.Count()-1);
2825
2826 return 0;
2827 }
2828
2829
2830 }
2831 delete ptra;
2832 break;
2833 }
2834 }
2835
2836
2837 // TODO(crash): check that the above .add succeeded.
2838 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2839 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2840 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2841 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2842 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2843 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2844 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2845 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2846 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2847 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2848 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2849 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2850
2851
2852 item_set = 0; //Do not make a drop.
2853
2854 switch(effect_type)
2855 {
2856 case -7:
2857 {
2858 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2859 Lwpns.add(w);
2860 break;
2861 }
2862 case -6:
2863 {
2864 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2865 Lwpns.add(w);
2866 break;
2867 }
2868 case -5:
2869 {
2870 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2871 Lwpns.add(w);
2872 break;
2873 }
2874 case -4:
2875 {
2876 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2877 Lwpns.add(w);
2878 break;
2879 }
2880 case -3: explode(1); break;
2881 case -2: explode(2); break;
2882 case -1: explode(0); break;
2883 case 0: break;
2884
2885 default:
2886 {
2887 //Dummy weapon function
2888 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2889 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2890 Lwpns.add(w);
2891 break;
2892 }
2893 }
2894
2895
2896 yofs = -32768;
2897 switch(guysbuf[new_id&0xFFF].type)
2898 {
2899 case eeGLEEOK:
2900 {
2901 Z_scripterrlog("Replacing a gleeok.\n");
2902 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2903 hp = -999;
2904 if (tempenemy) tempenemy->hp = -999;
2905 break;
2906
2907 }
2908 default:
2909 hp = -1000; break;
2910 }
2911 int mi = mapind(cur_map, screen_spawned);
2912 ++game->guys[mi];
2913 return 1;
2914
2915 }
2916 case edSPLIT:
2917 {
2918 for ( int32_t q = 0; q < dmisc4; q++ )
2919 {
2920 addenemy(screen_spawned,x,y,
2921 dmisc3+0x1000,-15);
2922
2923 }
2924 item_set = 0; //Do not make a drop.
2925 hp = -1000;
2926 return -1;
2927
2928 }
2929 case edSUMMON:
2930 {
2931 int32_t summon_count = zc::math::SafeMod(zc_oldrand(), dmisc4) + 1;
2932 for ( int32_t q = 0; q < summon_count; q++ )
2933 {
2934 int32_t x2=16*((zc_oldrand()%12)+2);
2935 int32_t y2=16*((zc_oldrand()%7)+2);
2936 addenemy(screen_spawned,
2937 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2938 x2,y2,
2939 dmisc3+0x1000,-15);
2940
2941 }
2942 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(x));
2943 return -1;
2944
2945 }
2946
2947 case edEXPLODESMALL:
2948 {
2949 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2950 Ewpns.add(ew);
2951 item_set = 0; //Should we make a drop?
2952 hp = -1000;
2953 return -1;
2954 }
2955
2956
2957 case edEXPLODEHARMLESS:
2958 {
2959 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2960 Ewpns.add(ew);
2961 ew->hyofs = -32768;
2962 item_set = 0; //Should we make a drop?
2963 hp = -1000;
2964 return -1;
2965 }
2966
2967
2968 case edEXPLODELARGE:
2969 {
2970 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2971 Ewpns.add(ew);
2972
2973 hp = -1000;
2974 return -1;
2975 }
2976
2977
2978 case edTRIGGERSECRETS:
2979 {
2980 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
2981 return -1;
2982 }
2983
2984 case edSTUNORCHINK:
2985
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 if(*power <= 0)
2986 {
2987 649 sfx(WAV_CHINK,pan(x));
2988 649 return 1;
2989 }
2990
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 1119 times.
2645 if (stunclk)
2991 {
2992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_IGNORE))
2993 return 0;
2994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_BLOCK))
2995 {
2996 sfx(WAV_CHINK,pan(x));
2997 return 1;
2998 }
2999 1119 }
3000 [[fallthrough]];
3001
3002 case edSTUNORIGNORE:
3003
2/2
✓ Branch 0 taken 959 times.
✓ Branch 1 taken 2502 times.
3461 if(*power <= 0)
3004 959 return 0;
3005
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 1952 times.
4454 if (stunclk)
3006 {
3007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3008 return 0;
3009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3010 {
3011 sfx(WAV_CHINK,pan(x));
3012 return 1;
3013 }
3014 1952 }
3015 [[fallthrough]];
3016
3017 case edSTUNONLY:
3018
7/10
✓ Branch 0 taken 4460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4460 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3913 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4139 times.
✓ Branch 9 taken 321 times.
4460 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3019 {
3020 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3021 321 return 1;
3022 }
3023
2/2
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 3198 times.
4139 if (stunclk)
3024 {
3025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3198 times.
3198 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3026 return 0;
3027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3198 times.
3198 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3028 {
3029 sfx(WAV_CHINK,pan(x));
3030 return 1;
3031 }
3032 3198 }
3033 4139 stunclk=160;
3034 4139 sfx(WAV_EHIT,pan(x));
3035 4139 return 1;
3036
3037 case edCHINKL1:
3038 if(*power >= 1*game->get_hero_dmgmult()) break;
3039 [[fallthrough]];
3040 case edCHINKL2:
3041
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3042 [[fallthrough]];
3043 case edCHINKL4:
3044
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3045 [[fallthrough]];
3046 case edCHINKL6:
3047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3048 [[fallthrough]];
3049 case edCHINKL8:
3050
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3051 [[fallthrough]];
3052 case edCHINKL10:
3053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3054 [[fallthrough]];
3055 case edCHINK:
3056 1074 sfx(WAV_CHINK,pan(x));
3057 1074 return 1;
3058
3059 case edIGNOREL1:
3060 if(*power > 0) break;
3061 [[fallthrough]];
3062
3063 case edIGNORE:
3064 22345 return 0;
3065
3066 case ed1HKO:
3067 525 *power = hp;
3068 525 return -3;
3069
3070 case ed2x:
3071 {
3072
1/2
✓ Branch 0 taken 497 times.
✗ Branch 1 not taken.
497 *power = zc_max(1,*power*2);
3073 //int32_t pow = *power;
3074 //*power = vbound((pow*2),0,214747);
3075 497 return -1;
3076 }
3077 case ed3x:
3078 {
3079
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 *power = zc_max(1,*power*3);
3080 //int32_t pow = *power;
3081 //*power = vbound((pow*3),0,214747);
3082 8 return -1;
3083 }
3084
3085 case ed4x:
3086 {
3087 *power = zc_max(1,*power*4);
3088 //int32_t pow = *power;
3089 //*power = vbound((pow*4),0,214747);
3090 return -1;
3091 }
3092
3093
3094 case edHEAL:
3095 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3096 //int32_t pow = *power;
3097 //*power = vbound((pow*-1),0,214747);
3098 //break;
3099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3100 158 return -1;
3101 }
3102 /*
3103 case edLEVELDAMAGE:
3104 {
3105 int32_t pow = *power;
3106 int32_t lvl = *level;
3107 *power = vbound((pow*lvl),0,214747);
3108 break;
3109 }
3110 case edLEVELREDUCTION:
3111 {
3112 int32_t pow = *power;
3113 int32_t lvl = *level;
3114 *power = vbound((pow/lvl),0,214747);
3115 break;
3116 }
3117 */
3118
3119 case edQUARTDAMAGE:
3120
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 3 times.
181 *power = zc_max(1,*power/2);
3121
3122 [[fallthrough]];
3123 case edHALFDAMAGE:
3124
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 191 times.
1188 *power = zc_max(1,*power/2);
3125 1188 break;
3126
3127 case edSWITCH:
3128 {
3129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(type)
3131 {
3132 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3133 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3134 return 0;
3135 }
3136 4 hooked_comborpos = rpos_t::None;
3137 4 hooked_layerbits = 0;
3138 4 switching_object = this;
3139 4 switch_hooked = true;
3140 4 Hero.doSwitchHook(game->get_switchhookstyle());
3141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3142 sfx(QMisc.miscsfx[sfxSWITCHED],pan(x));
3143 4 return 1;
3144 }
3145
3146 case 0:
3147 {
3148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96382 times.
96382 if(edef == edefSwitchHook)
3149 return -1;
3150
4/4
✓ Branch 0 taken 19592 times.
✓ Branch 1 taken 76790 times.
✓ Branch 2 taken 7811 times.
✓ Branch 3 taken 11781 times.
96382 if (stunclk && *power == 0)
3151 {
3152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11781 times.
11781 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3153 return 0;
3154
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 11755 times.
11781 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3155 {
3156 26 sfx(WAV_CHINK,pan(x));
3157 26 return 1;
3158 }
3159 11755 }
3160 96356 break;
3161 }
3162 }
3163
3164 97719 return -1;
3165 135235 }
3166
3167 135235 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3168 {
3169
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 int wuid = w?w->getUID():0;
3170
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3171
3172
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 if(fakeweap)
3173 Lwpns.add(w);
3174 135235 std::vector<int32_t> &ev = FFCore.eventData;
3175 135235 ev.clear();
3176 135235 ev.push_back(*power*10000);
3177 135235 ev.push_back(edef*10000);
3178 135235 ev.push_back(unblockable*10000);
3179 135235 ev.push_back(wpnId*10000);
3180 135235 ev.push_back(0);
3181 135235 ev.push_back(getUID());
3182 135235 ev.push_back(wuid);
3183
3184 135235 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3185 135235 *power = ev[0]/10000;
3186 135235 edef = ev[1]/10000;
3187 135235 unblockable = byte(ev[2]/10000);
3188 135235 wpnId = ev[3] / 10000;
3189 135235 bool nullify = ev[4]!=0;
3190 135235 ev.clear();
3191 135235 int ret = 0;
3192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135235 times.
135235 if(!nullify)
3193 {
3194 135235 ret = defendNew(wpnId, power, edef, unblockable);
3195
2/2
✓ Branch 0 taken 37690 times.
✓ Branch 1 taken 97545 times.
135235 if(ret < 0)
3196 {
3197 97545 ev.push_back(*power*10000);
3198 97545 ev.push_back(edef*10000);
3199 97545 ev.push_back(unblockable*10000);
3200 97545 ev.push_back(wpnId*10000);
3201 97545 ev.push_back(0);
3202 97545 ev.push_back(getUID());
3203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97545 times.
97545 ev.push_back(w?w->getUID():0);
3204
3205 97545 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3206 97545 *power = ev[0]/10000;
3207 97545 nullify = ev[4]!=0;
3208 97545 ev.clear();
3209 97545 }
3210 135235 }
3211
1/2
✓ Branch 0 taken 135235 times.
✗ Branch 1 not taken.
135235 if(fakeweap)
3212 Lwpns.remove(w);
3213
3214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135235 times.
135235 return nullify ? 0 : ret;
3215 }
3216
3217 108277 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3218 {
3219
2/2
✓ Branch 0 taken 107700 times.
✓ Branch 1 taken 577 times.
108277 if(!realweap) realweap = w;
3220 108277 int32_t wid = getWeaponID(w);
3221
3222 108277 int32_t edef = resolveEnemyDefence(w);
3223
2/2
✓ Branch 0 taken 14862 times.
✓ Branch 1 taken 93415 times.
108277 if(QHeader.zelda_version > 0x250)
3224 14862 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3225
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92422 times.
✗ Branch 2 not taken.
93415 switch(wid)
3226 {
3227 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3228 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3229 993 return defend(wpnId, power, edefSCRIPT);
3230
3231 case wWhistle:
3232 return -1;
3233
3234 default:
3235 92422 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3236 }
3237 108277 }
3238
3239
3240 // Check defenses without actually acting on them.
3241 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3242 {
3243
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3244 {
3245 case edSTUNONLY:
3246 474 return false;
3247 case edSTUNORCHINK:
3248 case edCHINK:
3249 15409 return unblockable&WPNUNB_BLOCK;
3250 case edSTUNORIGNORE:
3251 case edIGNORE:
3252 11050 return unblockable&WPNUNB_IGNR;
3253
3254 case edIGNOREL1:
3255 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3256 case edCHINKL1:
3257 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3258
3259 case edCHINKL2:
3260 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3261
3262 case edCHINKL4:
3263 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3264
3265 case edCHINKL6:
3266 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3267
3268 case edCHINKL8:
3269 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3270 }
3271
3272 469 return true;
3273 27402 }
3274
3275 // Do we do damage?
3276 // 0: takehit returns 0
3277 // 1: takehit returns 1
3278 // -1: do damage
3279 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3280 {
3281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3282 {
3283 switch(defense[edef])
3284 {
3285 case edIGNORE:
3286 return 0;
3287 case edIGNOREL1:
3288 case edSTUNORIGNORE:
3289 if(*power <= 0)
3290 return 0;
3291 }
3292
3293 sfx(WAV_CHINK,pan(x));
3294 return 1;
3295 }
3296
3297
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3298 {
3299 case edSTUNORCHINK:
3300 if(*power <= 0)
3301 {
3302 sfx(WAV_CHINK,pan(x));
3303 return 1;
3304 }
3305
3306 [[fallthrough]];
3307 case edSTUNORIGNORE:
3308 if(*power <= 0)
3309 return 0;
3310
3311 [[fallthrough]];
3312 case edSTUNONLY:
3313 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3314 return 1;
3315
3316 stunclk=160;
3317 sfx(WAV_EHIT,pan(x));
3318 return 1;
3319
3320 case edFREEZE:
3321 frozenclock=-1;
3322 //sfx(WAV_FREEZE,pan(x));
3323 return 1;
3324
3325 case edCHINKL1:
3326 if(*power >= 1*game->get_hero_dmgmult()) break;
3327 [[fallthrough]];
3328 case edCHINKL2:
3329 if(*power >= 2*game->get_hero_dmgmult()) break;
3330 [[fallthrough]];
3331 case edCHINKL4:
3332 if(*power >= 4*game->get_hero_dmgmult()) break;
3333 [[fallthrough]];
3334 case edCHINKL6:
3335 if(*power >= 6*game->get_hero_dmgmult()) break;
3336 [[fallthrough]];
3337 case edCHINKL8:
3338 if(*power >= 8*game->get_hero_dmgmult()) break;
3339 [[fallthrough]];
3340 case edCHINKL10:
3341 if(*power >= 10*game->get_hero_dmgmult()) break;
3342 [[fallthrough]];
3343 case edCHINK:
3344 sfx(WAV_CHINK,pan(x));
3345 return 1;
3346 case edTRIGGERSECRETS:
3347 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3348 break;
3349
3350 case edIGNOREL1:
3351 if(*power > 0) break;
3352 [[fallthrough]];
3353 case edIGNORE:
3354 800 return 0;
3355
3356 case ed1HKO:
3357 *power = hp;
3358 return -3;
3359
3360 case ed2x:
3361 {
3362 *power = zc_max(1,*power*2);
3363 //int32_t pow = *power;
3364 //*power = vbound((pow*2),0,214747);
3365 return -1;
3366 }
3367 case ed3x:
3368 {
3369 *power = zc_max(1,*power*3);
3370 //int32_t pow = *power;
3371 //*power = vbound((pow*3),0,214747);
3372 return -1;
3373 }
3374
3375 case ed4x:
3376 {
3377 *power = zc_max(1,*power*4);
3378 //int32_t pow = *power;
3379 //*power = vbound((pow*4),0,214747);
3380 return -1;
3381 }
3382
3383
3384 case edHEAL:
3385 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3386 //int32_t pow = *power;
3387 //*power = vbound((pow*-1),0,214747);
3388 //break;
3389 *power = zc_min(0,*power*-1);
3390 return -1;
3391 }
3392 /*
3393 case edLEVELDAMAGE:
3394 {
3395 int32_t pow = *power;
3396 int32_t lvl = *level;
3397 *power = vbound((pow*lvl),0,214747);
3398 break;
3399 }
3400 case edLEVELREDUCTION:
3401 {
3402 int32_t pow = *power;
3403 int32_t lvl = *level;
3404 *power = vbound((pow/lvl),0,214747);
3405 break;
3406 }
3407 */
3408
3409
3410 case edQUARTDAMAGE:
3411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3412
3413 [[fallthrough]];
3414 case edHALFDAMAGE:
3415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3416 7 break;
3417 }
3418
3419 193 return -1;
3420 993 }
3421
3422 // Defend against a particular item class.
3423 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3424 {
3425 int32_t def=-1;
3426
3427 switch(wpnId)
3428 {
3429 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3430 case wBrang:
3431 def = defend(wpnId, power, edefBRANG);
3432 break;
3433
3434 case wHookshot:
3435 def = defend(wpnId, power, edefHOOKSHOT);
3436 break;
3437
3438 // Anyway...
3439 case wBomb:
3440 def = defend(wpnId, power, edefBOMB);
3441 break;
3442
3443 case wSBomb:
3444 def = defend(wpnId, power, edefSBOMB);
3445 break;
3446
3447 case wArrow:
3448 def = defend(wpnId, power, edefARROW);
3449 break;
3450
3451 case wFire:
3452 def = defend(wpnId, power, edefFIRE);
3453 break;
3454
3455 case wWand:
3456 def = defend(wpnId, power, edefWAND);
3457 break;
3458
3459 case wMagic:
3460 def = defend(wpnId, power, edefMAGIC);
3461 break;
3462
3463 case wHammer:
3464 def = defend(wpnId, power, edefHAMMER);
3465 break;
3466
3467 case wSword:
3468 def = defend(wpnId, power, edefSWORD);
3469 break;
3470
3471 case wBeam:
3472 def = defend(wpnId, power, edefBEAM);
3473 break;
3474
3475 case wRefBeam:
3476 def = defend(wpnId, power, edefREFBEAM);
3477 break;
3478
3479 case wRefMagic:
3480 def = defend(wpnId, power, edefREFMAGIC);
3481 break;
3482
3483 case wRefFireball:
3484 def = defend(wpnId, power, edefREFBALL);
3485 break;
3486
3487 case wRefRock:
3488 def = defend(wpnId, power, edefREFROCK);
3489 break;
3490
3491 case wStomp:
3492 def = defend(wpnId, power, edefSTOMP);
3493 break;
3494
3495 case wCByrna:
3496 def = defend(wpnId, power, edefBYRNA);
3497 break;
3498
3499 case wScript1:
3500 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3501 else def = defend(wpnId, power, edefSCRIPT);
3502 break;
3503
3504 case wScript2:
3505 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3506 else def = defend(wpnId, power, edefSCRIPT);
3507 break;
3508
3509 case wScript3:
3510 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3511 else def = defend(wpnId, power, edefSCRIPT);
3512 break;
3513
3514 case wScript4:
3515 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3516 else def = defend(wpnId, power, edefSCRIPT);
3517 break;
3518
3519 case wScript5:
3520 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3521 else def = defend(wpnId, power, edefSCRIPT);
3522 break;
3523
3524 case wScript6:
3525 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3526 else def = defend(wpnId, power, edefSCRIPT);
3527 break;
3528
3529 case wScript7:
3530 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3531 else def = defend(wpnId, power, edefSCRIPT);
3532 break;
3533
3534 case wScript8:
3535 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3536 else def = defend(wpnId, power, edefSCRIPT);
3537 break;
3538
3539 case wScript9:
3540 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3541 else def = defend(wpnId, power, edefSCRIPT);
3542 break;
3543
3544 case wScript10:
3545 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3546 else def = defend(wpnId, power, edefSCRIPT);
3547 break;
3548
3549 case wWhistle:
3550 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3551 else break;
3552 break;
3553
3554 case wRefArrow:
3555 def = defend(wpnId, power, edefREFARROW);
3556 break;
3557 case wRefFire:
3558 def = defend(wpnId, power, edefREFFIRE);
3559 break;
3560 case wRefFire2:
3561 def = defend(wpnId, power, edefREFFIRE2);
3562 break;
3563
3564 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3565 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3566 //of the ten if the quest version is lower than N.
3567 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3568 //such as bool UseSeparatedScriptDefences. hah.
3569 default:
3570 //if(wpnId>=wScript1 && wpnId<=wScript10)
3571 // {
3572 // def = defend(wpnId, power, edefSCRIPT);
3573 // }
3574 // }
3575
3576 break;
3577 }
3578
3579 return def;
3580 }
3581
3582 // take damage or ignore it
3583 // 2 or -2: force wait a frame
3584 // < 0: damage (if any) dealt
3585 // > 0: blocked
3586 // 0: weapon passes through unhindered
3587 274677 int32_t enemy::takehit(weapon *w, weapon* realweap)
3588 {
3589
2/4
✓ Branch 0 taken 274677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 274677 times.
274677 if(fallclk||drownclk) return 0;
3590
2/2
✓ Branch 0 taken 72352 times.
✓ Branch 1 taken 202325 times.
274677 if(!realweap) realweap = w;
3591 274677 int32_t wpnId = w->id;
3592 274677 int32_t power = w->power;
3593 274677 int32_t wpnx = w->x;
3594 274677 int32_t wpny = w->y;
3595 274677 int32_t enemyHitWeapon = w->parentitem;
3596 int32_t wpnDir;
3597 274677 int32_t parent_item = w->parentitem;
3598
3599
2/2
✓ Branch 0 taken 274562 times.
✓ Branch 1 taken 115 times.
274677 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3600 {
3601 115 wpnId = w->useweapon;
3602 115 }
3603
3604 // If it's a boomerang that just bounced, use the opposite direction;
3605 // otherwise, it might bypass a shield. This probably won't handle
3606 // every case correctly, but it's better than having shields simply
3607 // not work against boomerangs.
3608
8/8
✓ Branch 0 taken 25236 times.
✓ Branch 1 taken 249441 times.
✓ Branch 2 taken 15681 times.
✓ Branch 3 taken 9555 times.
✓ Branch 4 taken 14419 times.
✓ Branch 5 taken 1262 times.
✓ Branch 6 taken 3308 times.
✓ Branch 7 taken 11111 times.
274677 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3609 11111 wpnDir = oppositeDir[w->dir];
3610 else
3611 263566 wpnDir = w->dir;
3612
3613
5/8
✓ Branch 0 taken 274677 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 274677 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 274677 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7320 times.
✓ Branch 7 taken 281997 times.
274677 if(dying || clk<0 || hclk>0 || superman)
3614 7320 return 0;
3615
3616 //Prevent boomerang from writing to hitby[] for more than one frame.
3617 //This also prevents stunlock.
3618 //if ( stunclk > 0 ) return 0;
3619 //this needs a rule for boomerangs that cannot stunlock!
3620 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3621 //sigh.
3622
3623 281997 int32_t ret = -1;
3624
3625 // This obscure quest rule...
3626
5/6
✓ Branch 0 taken 101723 times.
✓ Branch 1 taken 180274 times.
✓ Branch 2 taken 98021 times.
✓ Branch 3 taken 3702 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 98021 times.
281997 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3627 {
3628 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3629 3702 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3630 3702 wpnDir=zc_oldrand()&3;
3631
3632
4/4
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 3209 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 200 times.
3702 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3633 {
3634 200 wpnDir=down;
3635 200 }
3636
4/4
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 2904 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 305 times.
3502 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3637 {
3638 305 wpnDir=right;
3639 305 }
3640
4/4
✓ Branch 0 taken 2487 times.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 2194 times.
3197 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3641 {
3642 2194 wpnDir=up;
3643 2194 }
3644 else
3645 {
3646 1003 wpnDir=left;
3647 }
3648 3702 }
3649
3650 281997 int32_t xdir = dir;
3651 281997 shieldCanBlock=false;
3652
3653
4/4
✓ Branch 0 taken 270717 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 267950 times.
282759 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3654
6/6
✓ Branch 0 taken 18735 times.
✓ Branch 1 taken 15968 times.
✓ Branch 2 taken 26888 times.
✓ Branch 3 taken 257030 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 256922 times.
270717 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3655
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 255903 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 255141 times.
256922 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3656 )
3657 // The hammer should already be dealt with by subclasses (Walker etc.)
3658 {
3659
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 757 times.
✓ Branch 4 taken 5961 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 43 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 168 times.
✓ Branch 9 taken 1490 times.
47512 switch(wpnId)
3660 {
3661 // Weapons which shields protect against
3662 case wSword:
3663 case wWand:
3664
2/2
✓ Branch 0 taken 5959 times.
✓ Branch 1 taken 2 times.
5963 if(Hero.getCharging()>0)
3665 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3666
3667 [[fallthrough]];
3668 case wHookshot:
3669 case wHSHandle:
3670 case wBrang:
3671 6341 shieldCanBlock=true;
3672 6679 break;
3673
3674 case wBeam:
3675 case wRefBeam:
3676 // Mirror shielded enemies!
3677 #if 0
3678 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3679 {
3680 if(wpnId>wEnemyWeapons)
3681 return 0;
3682
3683 sfx(WAV_CHINK,pan(x));
3684 return 1;
3685 }
3686
3687 #endif
3688
3689 [[fallthrough]];
3690 case wRefRock:
3691 case wRefFireball:
3692 case wMagic:
3693 #if 0
3694 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3695 {
3696 sfx(WAV_CHINK,pan(x));
3697 return 3;
3698 }
3699
3700 #endif
3701
3702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(wpnId>wEnemyWeapons)
3703 return 0;
3704
3705 [[fallthrough]];
3706 case wArrow:
3707 411 case wRefArrow:
3708 default:
3709 1901 shieldCanBlock=true;
3710 1901 break;
3711
3712 // Bombs
3713 case wSBomb:
3714 case wBomb:
3715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3716 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3717 {
3718 sfx(WAV_CHINK,pan(x));
3719 return 0;
3720 }
3721 else break;
3722
3723 // Weapons which ignore shields
3724 case wWhistle:
3725 case wHammer:
3726 168 break;
3727
3728 // Weapons which shouldn't be removed by shields
3729 case wLitBomb:
3730 case wLitSBomb:
3731 case wWind:
3732 case wPhantom:
3733 case wSSparkle:
3734 case wBait:
3735 864 return 0;
3736
3737 case wFire:
3738 case wRefFire:
3739 case wRefFire2:
3740 ;
3741 757 }
3742 9167 }
3743
3744
8/8
✓ Branch 0 taken 103856 times.
✓ Branch 1 taken 106603 times.
✓ Branch 2 taken 432 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27419 times.
✓ Branch 5 taken 25184 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9057 times.
275588 switch(wpnId)
3745 {
3746 case wWhistle: //No longer completely ignore whistle weapons! -Z
3747 {
3748
3749
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
432 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3750 {
3751 432 return 0; break;
3752 }
3753 else
3754 {
3755 w->power = power = itemsbuf[parent_item].misc5;
3756 goto takehit_default;
3757 }
3758 break;
3759 }
3760
3761 case wPhantom:
3762 270 return 0;
3763
3764 case wLitBomb:
3765 case wLitSBomb:
3766 case wBait:
3767 case wWind:
3768 case wSSparkle:
3769 103856 return 0;
3770
3771 case wFSparkle:
3772
3773 // Only take sparkle damage if the sparkle's parent item is not
3774 // defended against.
3775
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 27402 times.
27419 if(enemyHitWeapon > -1)
3776 {
3777 27402 int32_t p = 0;
3778 27402 int32_t f = itemsbuf[enemyHitWeapon].type;
3779
3780
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3781 {
3782 case itype_arrow:
3783 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3784
3785 break;
3786
3787 case itype_cbyrna:
3788 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3789
3790 break;
3791
3792 case itype_brang:
3793
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3794
3795 469 break;
3796
3797 default:
3798 return 0;
3799 }
3800 469 }
3801
3802 486 wpnId = wSword;
3803 486 power = game->get_hero_dmgmult()>>1;
3804 486 goto takehit_default;
3805
3806 case wBrang:
3807 {
3808 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3809 25184 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3810 //preventing stunlock might be best, here. -Z
3811
2/2
✓ Branch 0 taken 5585 times.
✓ Branch 1 taken 19599 times.
25184 if(def >= 0) return def;
3812 19599 ret = def;
3813
3814 // Not hurt by 0-damage weapons
3815
2/2
✓ Branch 0 taken 3217 times.
✓ Branch 1 taken 16382 times.
19599 if(!(flags & guy_bhit))
3816 {
3817 16382 stunclk=160;
3818
3819
3/4
✓ Branch 0 taken 16382 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15071 times.
16382 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3820 {
3821
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3822 1311 goto hitclock;
3823 }
3824
3825 15071 break;
3826 }
3827
3828
2/2
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 2793 times.
3217 if(!power)
3829
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_brang))*game->get_hero_dmgmult();
3830 else
3831 424 hp-=power;
3832
3833 3217 goto hitclock;
3834 }
3835
3836 case wHookshot:
3837 {
3838 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3839 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3840
3841
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3842 1773 ret = def;
3843
3844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3845
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3846 {
3847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3848 1625 stunclk=160;
3849
3850
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3851 {
3852
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3853 549 goto hitclock;
3854 }
3855
3856 1076 break;
3857 }
3858
3859
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_hookshot))*game->get_hero_dmgmult();
3860 else
3861 45 hp-=power;
3862
3863 148 goto hitclock;
3864 }
3865 break;
3866
3867 case wHSHandle:
3868 {
3869
3/4
✓ Branch 0 taken 9057 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8534 times.
9057 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3870 523 return 0;
3871
3872
3/4
✓ Branch 0 taken 6094 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8534 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3874
3875 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3876
6/8
✓ Branch 0 taken 2788 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2788 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2788 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2286 times.
10246 if(!(type==eePEAHAT || type==eeAQUA || type==eeMANHAN || (type==eeWIZZ && !ignorehookshot)
3877
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3890 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2178 times.
2788 || (type==eeWALK && dmisc9==e9tPOLSVOICE) || (type==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3878 2178 return 0;
3879
3880 12102 power = game->get_hero_dmgmult();
3881 12588 }
3882
3883 takehit_default:
3884
3885 [[fallthrough]];
3886 default:
3887 // Work out the defenses!
3888 {
3889 107699 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3890
3891
2/2
✓ Branch 0 taken 31754 times.
✓ Branch 1 taken 75945 times.
107699 if(def >= 0)
3892 31754 return def;
3893
2/2
✓ Branch 0 taken 75485 times.
✓ Branch 1 taken 460 times.
75945 else if(def == -3) // OHKO... doesn't 'hit' the weapon?
3894 460 ret = 0;
3895 }
3896
3897
2/2
✓ Branch 0 taken 75928 times.
✓ Branch 1 taken 17 times.
151875 if(!power)
3898 {
3899
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 15 times.
17 if(flags & guy_bhit)
3900 2 hp-=1;
3901 else
3902 {
3903 // Don't make a long chain of 'stun' hits
3904
5/8
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✓ Branch 7 taken 4 times.
15 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3905 4 return 1;
3906
3907
3908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!switch_hooked)
3909 11 stunclk=160;
3910 11 break;
3911 }
3912 2 }
3913 75928 else hp-=power;
3914
3915 hitclock:
3916 81166 hclk=33;
3917
3918 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3919
2/2
✓ Branch 0 taken 36106 times.
✓ Branch 1 taken 45060 times.
81166 if((dir&2)==(w->dir&2))
3920 {
3921 45060 sclk=(w->dir<<8)+16;
3922 45060 }
3923 81166 }
3924
3925
5/6
✓ Branch 0 taken 77725 times.
✓ Branch 1 taken 19599 times.
✓ Branch 2 taken 22015 times.
✓ Branch 3 taken 75309 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22015 times.
97324 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3926 {
3927 22015 fading=fade_blue_poof;
3928 22015 }
3929
3930
6/6
✓ Branch 0 taken 88602 times.
✓ Branch 1 taken 8722 times.
✓ Branch 2 taken 46937 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2347 times.
✓ Branch 5 taken 44590 times.
97324 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3931 {
3932
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if( hitsfx > 0 ) //user-set hit sound.
3933 {
3934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if (!dying) //don't play the hit sound on death! -Z
3935 11069 sfx(hitsfx, pan(x));
3936 11069 }
3937 else sfx(WAV_EHIT, pan(x)); //Don't play the hardcoded sound if the user sets a custom one.
3938 11069 }
3939 else //2.50.2 or earlier
3940 {
3941 86255 sfx(WAV_EHIT, pan(x));
3942 86255 sfx(hitsfx, pan(x));
3943 }
3944
2/2
✓ Branch 0 taken 97295 times.
✓ Branch 1 taken 29 times.
97324 if(type==eeGUY)
3945 29 sfx(WAV_EDEAD, pan(x));
3946
3947 // Penetrating weapons
3948
4/4
✓ Branch 0 taken 95310 times.
✓ Branch 1 taken 2014 times.
✓ Branch 2 taken 88404 times.
✓ Branch 3 taken 8920 times.
97324 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3949 {
3950 8920 int32_t item=enemyHitWeapon;
3951
3952
2/2
✓ Branch 0 taken 1752 times.
✓ Branch 1 taken 7168 times.
8920 if(wpnId==wArrow)
3953 {
3954 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3955
5/6
✓ Branch 0 taken 1624 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1752 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].type == itype_arrow))
3956 379 return 0;
3957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1373 times.
1373 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3958 //if(item<0)
3959 else
3960 1373 item=current_item_id(itype_arrow);
3961 1373 }
3962
3963 else
3964 {
3965
3966 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3967
3/6
✓ Branch 0 taken 7150 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7150 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7168 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].type == itype_sword))
3968 return 0;
3969
3970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7168 times.
7168 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3971 else
3972 //if(item<0)
3973 7168 item=current_item_id(itype_sword);
3974 }
3975 8541 }
3976
3977 96945 return ret;
3978 278037 }
3979
3980 63955693 bool enemy::dont_draw() const
3981 {
3982
6/6
✓ Branch 0 taken 63491180 times.
✓ Branch 1 taken 464513 times.
✓ Branch 2 taken 63420273 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 175068 times.
✓ Branch 5 taken 63316112 times.
63955693 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3983 639581 return true;
3984
3985
2/2
✓ Branch 0 taken 1375509 times.
✓ Branch 1 taken 61940603 times.
63316112 if(flags&guy_invisible)
3986 1375509 return true;
3987
3988
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 61940171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
61940603 if(flags&guy_lens_only && !lensclk)
3989 return true;
3990
3991 61940603 return false;
3992 63955693 }
3993
3994 #define DRAW_NORMAL 2
3995 #define DRAW_CLOAKED 1
3996 #define DRAW_INVIS 0
3997 // base drawing function to be used by all derived classes instead of
3998 // sprite::draw()
3999 46383919 void enemy::draw(BITMAP *dest)
4000 {
4001 46383919 didScriptThisFrame = false; //Since there's no better place to put it
4002
6/6
✓ Branch 0 taken 45618787 times.
✓ Branch 1 taken 765132 times.
✓ Branch 2 taken 45536137 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317591 times.
✓ Branch 5 taken 45301196 times.
46383919 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4003 1082723 return;
4004
2/2
✓ Branch 0 taken 2770966 times.
✓ Branch 1 taken 42530230 times.
45301196 if(flags&guy_invisible)
4005 2770966 return;
4006
4007 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4008 // be cloaked if they have "invisible displays as cloaked" checked.
4009
4010 42530230 byte canSee = DRAW_NORMAL;
4011 //Enemy specific stuff
4012
2/2
✓ Branch 0 taken 42529066 times.
✓ Branch 1 taken 1164 times.
42530230 if ( editorflags & ENEMY_FLAG1 )
4013 {
4014 1164 canSee = DRAW_INVIS;
4015
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4016
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4017 {
4018 if (game->item[dmisc13])
4019 {
4020 canSee = DRAW_NORMAL;
4021 }
4022 //else if ( lensclk && getlensid.flags SHOWINVIS )
4023 //{
4024 //
4025 //}
4026 //else
4027 //{
4028 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4029 // //otherwisem invisible
4030 //}
4031 }
4032 1164 }
4033 //Room specific
4034 42530230 mapscr* scr = get_scr(screen_spawned);
4035
2/2
✓ Branch 0 taken 40359031 times.
✓ Branch 1 taken 2171199 times.
42530230 if (scr->flags3&fINVISROOM)
4036 {
4037
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && type!=eeGANON) canSee = DRAW_CLOAKED;
4039 2171199 }
4040 //Lens check
4041
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 42502693 times.
42530230 if (lensclk)
4042 {
4043
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4044 {
4045
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4046 432 }
4047 27537 }
4048 else
4049 {
4050
2/2
✓ Branch 0 taken 42429277 times.
✓ Branch 1 taken 73416 times.
42502693 if(flags&guy_lens_only)
4051 73416 canSee = DRAW_INVIS;
4052 }
4053
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 42455650 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
42530230 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4054
3/4
✓ Branch 0 taken 42229646 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 42229646 times.
✗ Branch 3 not taken.
42530230 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4055
4056
2/2
✓ Branch 0 taken 42455650 times.
✓ Branch 1 taken 74580 times.
42530230 if (canSee == DRAW_INVIS)
4057 74580 return;
4058
4059
4/4
✓ Branch 0 taken 42452423 times.
✓ Branch 1 taken 3227 times.
✓ Branch 2 taken 1416 times.
✓ Branch 3 taken 42451007 times.
42455650 if(fallclk||drownclk)
4060 {
4061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4643 times.
4643 if (canSee == DRAW_CLOAKED)
4062 {
4063 sprite::drawcloaked(dest);
4064 }
4065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4643 times.
4643 else if (canSee == DRAW_NORMAL)
4066 {
4067 4643 sprite::draw(dest);
4068 4643 }
4069 4643 return;
4070 }
4071 42451007 int32_t cshold=cs;
4072
4073
2/2
✓ Branch 0 taken 945772 times.
✓ Branch 1 taken 41505235 times.
42451007 if(dying)
4074 {
4075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945772 times.
945772 if(clk2>=19)
4076 {
4077 if(!(clk2&2))
4078 {
4079 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4080 if (canSee == DRAW_CLOAKED)
4081 {
4082 sprite::drawcloaked(dest);
4083 }
4084 else if (canSee == DRAW_NORMAL)
4085 {
4086 sprite::draw(dest);
4087 }
4088 }
4089 return;
4090 }
4091
4092 945772 flip = 0;
4093 945772 tile = wpnsbuf[spr_death].tile;
4094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945772 times.
945772 if ( do_animation )
4095 {
4096 945772 int32_t offs = 0;
4097
2/2
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 92660 times.
945772 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4098 {
4099
2/2
✓ Branch 0 taken 89665 times.
✓ Branch 1 taken 2995 times.
92660 if(clk2 > 2)
4100 {
4101 2995 spr_death_anim_clk=0;
4102 2995 clk2=1;
4103
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2978 times.
2995 if(hp > -1000)
4104 2978 death_sfx();
4105 2995 }
4106
4/4
✓ Branch 0 taken 66415 times.
✓ Branch 1 taken 26245 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 65339 times.
92660 if(clk2==1 && spr_death_anim_clk>-1)
4107 {
4108 65339 ++clk2;
4109
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 62957 times.
65339 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4110
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 65194 times.
65339 spr_death_anim_frm *= zc_max(1,txsz);
4111 65339 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4112
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 65239 times.
65339 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4113
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 62957 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 65337 times.
✓ Branch 4 taken 62370 times.
✓ Branch 5 taken 2969 times.
65339 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4114 {
4115 2969 spr_death_anim_clk=-1;
4116 2969 clk2=1;
4117 2969 }
4118 65339 }
4119 92660 tile += spr_death_anim_frm;
4120 92660 }
4121
2/2
✓ Branch 0 taken 315607 times.
✓ Branch 1 taken 537505 times.
853112 else if(BSZ)
4122 {
4123
2/2
✓ Branch 0 taken 248172 times.
✓ Branch 1 taken 67435 times.
315607 offs = zc_min((15-clk2)/3,4);
4124 315607 }
4125
4/4
✓ Branch 0 taken 358415 times.
✓ Branch 1 taken 179090 times.
✓ Branch 2 taken 179079 times.
✓ Branch 3 taken 179336 times.
537505 else if(clk2>6 && clk2<=12)
4126 {
4127 179336 offs = 1;
4128 179336 }
4129
4130
2/2
✓ Branch 0 taken 497279 times.
✓ Branch 1 taken 448493 times.
945772 if(offs)
4131 {
4132
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 448043 times.
448493 offs *= zc_max(1,txsz);
4133 448493 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4134
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 448055 times.
448493 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4135 448493 }
4136 945772 tile += offs;
4137 945772 }
4138
4139
6/6
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 92660 times.
✓ Branch 2 taken 537505 times.
✓ Branch 3 taken 315607 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348323 times.
945772 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4140 597449 cs = wpnsbuf[spr_death].csets&15;
4141 else
4142 348323 cs = (((clk2+5)>>1)&3)+6;
4143 945772 }
4144
3/4
✓ Branch 0 taken 1275681 times.
✓ Branch 1 taken 40229554 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1275681 times.
41505235 else if(hclk>0 && getCanFlicker())
4145 {
4146 1275681 cs = getFlashingCSet();
4147 1275681 }
4148 //draw every other frame for flickering enemies
4149
2/2
✓ Branch 0 taken 304540 times.
✓ Branch 1 taken 42146467 times.
42451007 if (is_hitflickerframe(false))
4150 {
4151
5/6
✓ Branch 0 taken 111978 times.
✓ Branch 1 taken 192562 times.
✓ Branch 2 taken 97 times.
✓ Branch 3 taken 111881 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 192659 times.
304540 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4152
3/4
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 56509 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
304540 if (game->get_spriteflickercolor() || temp_flicker_color)
4153 {
4154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56509 times.
56509 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4155 56509 sprite_flicker_color = temp_flicker_color;
4156 56509 sprite::draw(dest);
4157 56509 }
4158 304540 }
4159 else
4160 {
4161
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 41921305 times.
42146467 if (canSee == DRAW_CLOAKED)
4162 {
4163 225162 sprite::drawcloaked(dest);
4164 225162 }
4165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41921305 times.
41921305 else if (canSee == DRAW_NORMAL)
4166 {
4167
1/2
✓ Branch 0 taken 41921305 times.
✗ Branch 1 not taken.
41921305 if ( frozenclock < 0 )
4168 {
4169 if ( frozentile > 0 ) tile = frozentile;
4170 loadpalset(csBOSS,frozencset);
4171 }
4172 41921305 sprite::draw(dest);
4173 41921305 }
4174 }
4175 42451007 cs=cshold;
4176 46383919 }
4177
4178 //old zc bosses
4179 40956281 void enemy::drawzcboss(BITMAP *dest)
4180 {
4181 40956281 didScriptThisFrame = false; //Since there's no better place to put it
4182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40956281 times.
40956281 if(dont_draw())
4183 return;
4184
4185 40956281 int32_t cshold=cs;
4186
4187
2/2
✓ Branch 0 taken 784546 times.
✓ Branch 1 taken 40171735 times.
40956281 if(dying)
4188 {
4189
2/2
✓ Branch 0 taken 4248 times.
✓ Branch 1 taken 780298 times.
784546 if(clk2>=19)
4190 {
4191
2/2
✓ Branch 0 taken 2124 times.
✓ Branch 1 taken 2124 times.
4248 if(!(clk2&2))
4192 2124 sprite::drawzcboss(dest);
4193
4194 4248 return;
4195 }
4196
4197 780298 flip = 0;
4198 780298 tile = wpnsbuf[spr_death].tile;
4199
4200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780298 times.
780298 if ( do_animation )
4201 {
4202
2/2
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4736 times.
780298 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4203 {
4204
2/2
✓ Branch 0 taken 4724 times.
✓ Branch 1 taken 12 times.
4736 if(clk2 > 2)
4205 {
4206 12 spr_death_anim_clk=0;
4207 12 clk2=1;
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(hp > -1000)
4209 12 death_sfx();
4210 12 }
4211
4/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 4351 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 196 times.
4736 if(clk2==1 && spr_death_anim_clk>-1)
4212 {
4213 196 ++clk2;
4214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 spr_death_anim_frm *= zc_max(1,txsz);
4216 196 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4218
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
✓ Branch 4 taken 188 times.
✓ Branch 5 taken 8 times.
196 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4219 {
4220 8 spr_death_anim_clk=-1;
4221 8 clk2=1;
4222 8 }
4223 196 }
4224 4736 tile += spr_death_anim_frm;
4225 4736 }
4226
2/2
✓ Branch 0 taken 278586 times.
✓ Branch 1 taken 496976 times.
775562 else if(BSZ)
4227
2/2
✓ Branch 0 taken 219134 times.
✓ Branch 1 taken 59452 times.
278586 tile += zc_min((15-clk2)/3,4);
4228
4/4
✓ Branch 0 taken 331281 times.
✓ Branch 1 taken 165695 times.
✓ Branch 2 taken 165538 times.
✓ Branch 3 taken 165743 times.
496976 else if(clk2>6 && clk2<=12)
4229 165743 ++tile;
4230 780298 }
4231
4232
6/6
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4736 times.
✓ Branch 2 taken 496976 times.
✓ Branch 3 taken 278586 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 313104 times.
780298 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4233 467194 cs = wpnsbuf[spr_death].csets&15;
4234 else
4235 313104 cs = (((clk2+5)>>1)&3)+6;
4236 780298 }
4237
2/2
✓ Branch 0 taken 38957045 times.
✓ Branch 1 taken 1214690 times.
40171735 else if(hclk>0)
4238 {
4239 1214690 cs = getFlashingCSet();
4240 1214690 }
4241
4242 40952033 mapscr* scr = get_scr(screen_spawned);
4243
4244
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38906414 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40959576 if((scr->flags3&fINVISROOM) &&
4245
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4247 7543 lensclk) && type!=eeGANON)
4248 {
4249 7543 sprite::drawcloaked(dest);
4250 7543 }
4251 else
4252 {
4253
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40921017 times.
40944490 if (is_hitflickerframe(true))
4254 {
4255
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4256
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4257 {
4258 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4259 sprite_flicker_color = temp_flicker_color;
4260 sprite::drawzcboss(dest);
4261 }
4262 23473 }
4263 else
4264 40921017 sprite::drawzcboss(dest);
4265 }
4266
4267 40952033 cs=cshold;
4268 40956281 }
4269
4270
4271 // similar to the overblock function--can do up to a 32x32 sprite
4272 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4273 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4274 {
4275 323235 int32_t thold=tile;
4276 323235 int32_t t1=tile;
4277 323235 int32_t t2=tile+20;
4278 323235 int32_t t3=tile+1;
4279 323235 int32_t t4=tile+21;
4280
4281
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4282 {
4283 case 1:
4284 enemy::drawzcboss(dest);
4285 break;
4286
4287 case 3:
4288 if(flip&2)
4289 zc_swap(t1,t2);
4290
4291 tile=t1;
4292 enemy::drawzcboss(dest);
4293 tile=t2;
4294 yofs+=16;
4295 enemy::drawzcboss(dest);
4296 yofs-=16;
4297 break;
4298
4299 case 5:
4300 t2=tile+1;
4301
4302 if(flip&1)
4303 zc_swap(t1,t2);
4304
4305 tile=t1;
4306 enemy::drawzcboss(dest);
4307 tile=t2;
4308 xofs+=16;
4309 enemy::drawzcboss(dest);
4310 xofs-=16;
4311 break;
4312
4313 case 15:
4314
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4315 {
4316 6756 zc_swap(t1,t3);
4317 6756 zc_swap(t2,t4);
4318 6756 }
4319
4320
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4321 {
4322 zc_swap(t1,t2);
4323 zc_swap(t3,t4);
4324 }
4325
4326 323235 tile=t1;
4327 323235 enemy::drawzcboss(dest);
4328 323235 tile=t2;
4329 323235 yofs+=16;
4330 323235 enemy::drawzcboss(dest);
4331 323235 yofs-=16;
4332 323235 tile=t3;
4333 323235 xofs+=16;
4334 323235 enemy::drawzcboss(dest);
4335 323235 tile=t4;
4336 323235 yofs+=16;
4337 323235 enemy::drawzcboss(dest);
4338 323235 xofs-=16;
4339 323235 yofs-=16;
4340 323235 break;
4341 }
4342
4343 323235 tile=thold;
4344 323235 }
4345
4346 22435587 bool enemy::can_drawshadow() const
4347 {
4348
4/4
✓ Branch 0 taken 20420497 times.
✓ Branch 1 taken 2015090 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 19893579 times.
22435587 if(dont_draw() || isSideViewGravity())
4349 2542008 return false;
4350
4351
2/2
✓ Branch 0 taken 356303 times.
✓ Branch 1 taken 19537276 times.
19893579 if(dying)
4352 356303 return false;
4353
4354 19537276 mapscr* scr = get_scr(screen_spawned);
4355
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 17819027 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 19190266 times.
19537276 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4356 19537276 (darkroom))
4357 347010 return false;
4358
4359
6/6
✓ Branch 0 taken 17381648 times.
✓ Branch 1 taken 1808618 times.
✓ Branch 2 taken 17107109 times.
✓ Branch 3 taken 274539 times.
✓ Branch 4 taken 16507954 times.
✓ Branch 5 taken 599155 times.
19190266 if(z <= 0 && fakez <= 0 && enemycanfall(id, false))
4360 16507954 return false;
4361
4362
2/2
✓ Branch 0 taken 21604 times.
✓ Branch 1 taken 2660708 times.
2682312 if(shadow_overpit())
4363 21604 return false;
4364
4365 2660708 return true;
4366 22435587 }
4367 19059923 void enemy::drawshadow(BITMAP *dest, bool translucent)
4368 {
4369
2/2
✓ Branch 0 taken 17351358 times.
✓ Branch 1 taken 1708565 times.
19059923 if(!can_drawshadow())
4370 17351358 return;
4371
4/4
✓ Branch 0 taken 1109410 times.
✓ Branch 1 taken 599155 times.
✓ Branch 2 taken 847 times.
✓ Branch 3 taken 1108563 times.
1708565 if(enemycanfall(id, false) && shadowtile == 0)
4372 847 shadowtile = wpnsbuf[spr_shadow].tile;
4373
4374 1708565 sprite::drawshadow(dest,translucent);
4375 19059923 }
4376
4377 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4378 {
4379 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4380
4381
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4382 {
4383 129181 xofs-=mx;
4384 129181 yofs-=my;
4385 129181 enemy::draw(sub);
4386 129181 xofs+=mx;
4387 129181 yofs+=my;
4388 129181 destroy_bitmap(sub);
4389 129181 }
4390 else
4391 enemy::draw(dest);
4392 129181 }
4393
4394 39 void enemy::init_size_flags()
4395 {
4396
3/6
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 39 times.
39 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4397
4/6
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 16 times.
39 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4398
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
39 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4399
3/4
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
39 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4400
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
39 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4401
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 28 times.
39 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4402
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 28 times.
39 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4403
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
39 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4404
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
39 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4405 {
4406 2 yofs = (int32_t)d->yofs;
4407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4408 2 }
4409
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2 times.
39 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4410 39 }
4411
4412 // override hit detection to check for invicibility, stunned, etc
4413 118316701 bool enemy::hit()
4414 {
4415
4/4
✓ Branch 0 taken 116839534 times.
✓ Branch 1 taken 1477167 times.
✓ Branch 2 taken 114653834 times.
✓ Branch 3 taken 2185700 times.
118316701 if(dying || hclk>0) return false;
4416 114653834 return sprite::hit();
4417 118316701 }
4418 730351 bool enemy::hit(sprite *s)
4419 {
4420
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4421 713374 return sprite::hit(s);
4422 730351 }
4423
4424 45790630 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4425 {
4426
2/2
✓ Branch 0 taken 4116536 times.
✓ Branch 1 taken 41674094 times.
45790630 if(!hit()) return false;
4427 41674094 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4428 45790630 }
4429 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4430 {
4431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4432 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4433 78011 }
4434
4435 14262185 bool enemy::hit(weapon *w)
4436 {
4437
2/2
✓ Branch 0 taken 1734411 times.
✓ Branch 1 taken 12527774 times.
14262185 if(!hit()) return false;
4438
4439
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 5880392 times.
12527774 if (replay_version_check(0, 14))
4440 {
4441
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4442 225051 return false;
4443 6422331 return sprite::hit(w);
4444 }
4445 5880392 return w->hit(this);
4446 14262185 }
4447
4448 39141799 bool enemy::can_pitfall(bool checkspawning)
4449 {
4450
4/4
✓ Branch 0 taken 37562469 times.
✓ Branch 1 taken 1579330 times.
✓ Branch 2 taken 37541720 times.
✓ Branch 3 taken 1600079 times.
39141799 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4451
2/2
✓ Branch 0 taken 30861956 times.
✓ Branch 1 taken 6679764 times.
37541720 switch(guysbuf[id&0xFFF].type)
4452 {
4453 case eeAQUA:
4454 case eeDIG:
4455 case eeDONGO:
4456 case eeFAIRY:
4457 case eeGANON:
4458 case eeGHOMA:
4459 case eeGLEEOK:
4460 case eeGUY:
4461 case eeLANM:
4462 case eeMANHAN:
4463 case eeMOLD:
4464 case eeNONE:
4465 case eePATRA:
4466 case eeZORA:
4467 6679764 return false; //Disallowed types
4468 default:
4469 30861956 return true;
4470 }
4471 39141799 }
4472 //Handle death
4473 45071 bool enemy::death_event()
4474 {
4475 45071 std::vector<int32_t> &ev = FFCore.eventData;
4476 45071 ev.clear();
4477 45071 ev.push_back(10000);
4478 45071 ev.push_back(getUID());
4479
4480 45071 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4481 45071 bool is_still_dying = ev[0];
4482 45071 ev.clear();
4483 45071 return is_still_dying;
4484 }
4485 39022651 void enemy::try_death(bool force_kill)
4486 {
4487
8/8
✓ Branch 0 taken 38964550 times.
✓ Branch 1 taken 58101 times.
✓ Branch 2 taken 38964506 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 46559 times.
✓ Branch 5 taken 38917947 times.
✓ Branch 6 taken 1532 times.
✓ Branch 7 taken 45027 times.
39022651 if(!dying && (force_kill || (hp<=0 && !immortal)))
4488 {
4489
1/2
✓ Branch 0 taken 45071 times.
✗ Branch 1 not taken.
45071 if (!death_event())
4490 return;
4491
4492
4/4
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 45014 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 51 times.
45071 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4493 {
4494
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 51 times.
109 for(int32_t i=0; i<items.Count(); i++)
4495 {
4496
4/4
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 51 times.
58 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4497 {
4498
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 10 times.
51 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4499 {
4500
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4501 {
4502 7 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4503 7 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4504 7 }
4505 else
4506 {
4507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4508 {
4509 items.spr(i)->x = x+(txsz-1)*8;
4510 items.spr(i)->y = y-2+(tysz-1)*8;
4511 }
4512 else
4513 {
4514 3 items.spr(i)->x = x;
4515 3 items.spr(i)->y = y - 2;
4516 }
4517 }
4518 10 items.spr(i)->z = z;
4519 10 items.spr(i)->fakez = fakez;
4520 10 }
4521 else
4522 {
4523 41 items.spr(i)->x = x;
4524 41 items.spr(i)->y = y - 2;
4525 }
4526 51 }
4527 58 }
4528 51 }
4529
4530 45071 dying=true;
4531
4532
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 45037 times.
45071 if(fading==fade_flash_die)
4533 34 clk2=19+18*4;
4534 else
4535 {
4536 45037 clk2 = BSZ ? 15 : 19;
4537
4538
2/2
✓ Branch 0 taken 21095 times.
✓ Branch 1 taken 23942 times.
45037 if(fading!=fade_blue_poof)
4539 23942 fading=0;
4540 }
4541
4542
2/2
✓ Branch 0 taken 45014 times.
✓ Branch 1 taken 57 times.
45071 if(itemguy)
4543 {
4544 57 screen_item_set_state(screen_spawned, ScreenItemState::None);
4545 57 item_set=0;
4546 57 }
4547
6/6
✓ Branch 0 taken 44017 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 35248 times.
✓ Branch 3 taken 8769 times.
✓ Branch 4 taken 33759 times.
✓ Branch 5 taken 1489 times.
45071 if (screen_spawned < 128 && count_enemy && !script_spawned)
4548 33759 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4549 45071 }
4550 39022651 }
4551
4552 // --==**==--
4553
4554 // Movement routines that can be used by derived classes as needed
4555
4556 // --==**==--
4557
4558 580449 void enemy::fix_coords(bool bound)
4559 {
4560
1/2
✓ Branch 0 taken 580449 times.
✗ Branch 1 not taken.
580449 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4561
1/2
✓ Branch 0 taken 580449 times.
✗ Branch 1 not taken.
580449 if(moveflags & move_ignore_screenedge) bound = false;
4562
4563
2/2
✓ Branch 0 taken 85032 times.
✓ Branch 1 taken 495417 times.
580449 if(bound)
4564 {
4565 495417 int w = world_w;
4566 495417 int h = world_h;
4567
4568
1/2
✓ Branch 0 taken 495417 times.
✗ Branch 1 not taken.
495417 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4569 {
4570
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 495415 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
495417 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4571
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 495415 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
495417 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4572 495417 }
4573 else
4574 {
4575 x=vbound(x, 0, w-16);
4576 y=vbound(y, 0, h-16);
4577 }
4578 495417 }
4579
4580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 580449 times.
580449 if(!OUTOFBOUNDS(id, x, y))
4581 {
4582 580449 do_fix(x, 16, true);
4583
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 579310 times.
580449 if(isSideViewGravity())
4584 1139 do_fix(y,8,true);
4585 579310 else do_fix(y,16,true);
4586 580449 }
4587 580449 }
4588 9316 bool enemy::cannotpenetrate()
4589 {
4590
4/4
✓ Branch 0 taken 9135 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 9097 times.
9316 return (type == eeAQUA || type == eeMANHAN || type == eeGHOMA);
4591 }
4592
4593 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4594 {
4595 bool ok;
4596 562 int32_t dx = 0, dy = 0;
4597 562 int32_t sv = 8;
4598
4599 //Why is this here??? Why is it needed???
4600 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4601
4602
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4603 {
4604 case 8:
4605 case up:
4606
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4607 return false;
4608
4609 69 dy = dy1-s;
4610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4612 69 break;
4613
4614 case 12:
4615 case down:
4616
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4617 return false;
4618
4619 51 dy = dy2+s;
4620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4621 51 break;
4622
4623 case 14:
4624 case left:
4625 47 dx = dx1-s;
4626 47 sv = ((isSideViewGravity())?7:8);
4627
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4628
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4629 47 break;
4630
4631 case 10:
4632 case right:
4633 85 dx = dx2+s;
4634 85 sv = ((isSideViewGravity())?7:8);
4635
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4636 85 break;
4637
4638 case 9:
4639 case r_up:
4640 94 dx = dx2+s;
4641 94 dy = dy1-s;
4642
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4644 94 break;
4645
4646 case 11:
4647 case r_down:
4648 78 dx = dx2+s;
4649 78 dx = dy2+s;
4650
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4652 78 break;
4653
4654 case 13:
4655 case l_down:
4656 57 dx = dx1-s;
4657 57 dy = dy2+s;
4658
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4660 57 break;
4661
4662 case 15:
4663 case l_up:
4664 81 dx = dx1-s;
4665 81 dy = dy1-s;
4666
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4668 81 break;
4669
4670 default:
4671 db=99;
4672 return true;
4673 }
4674
4675 562 return ok;
4676 562 }
4677
4678
4679
4680
4681 // returns true if next step is ok, false if there is something there
4682 7645239 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4683 {
4684 7645239 bool ok = false; //initialise the var, son't just declare it
4685 7645239 int32_t dx = 0, dy = 0;
4686 7645239 int32_t sv = 8;
4687 7645239 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4688 //Why is this here??? Why is it needed???
4689 7645239 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7645239 times.
7645239 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7645239 times.
7645239 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4692
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 7645155 times.
7645239 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4693
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 7645155 times.
7645239 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4694 7645239 bool offgrid = OFFGRID_ENEMY;
4695
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7637948 times.
7645239 if(!offgrid)
4696 {
4697 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4698
1/2
✓ Branch 0 taken 7637948 times.
✗ Branch 1 not taken.
7637948 if(usehei<16)usehei=16;
4699
1/2
✓ Branch 0 taken 7637948 times.
✗ Branch 1 not taken.
7637948 if(usewid<16)usewid=16;
4700 7637948 }
4701
9/9
✓ Branch 0 taken 1384486 times.
✓ Branch 1 taken 1156763 times.
✓ Branch 2 taken 1279152 times.
✓ Branch 3 taken 1269730 times.
✓ Branch 4 taken 558497 times.
✓ Branch 5 taken 666174 times.
✓ Branch 6 taken 625432 times.
✓ Branch 7 taken 584251 times.
✓ Branch 8 taken 120754 times.
7645239 switch(ndir) //need to check every 8 pixels between two points
4702 {
4703 case 8:
4704 case up:
4705 {
4706
4/4
✓ Branch 0 taken 165069 times.
✓ Branch 1 taken 1219417 times.
✓ Branch 2 taken 164409 times.
✓ Branch 3 taken 660 times.
1384486 if(enemycanfall(id) && isSideViewGravity())
4707 660 return false;
4708
4709 1383826 dy = dy1-s;
4710
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1383346 times.
1383826 special = (special==spw_clipbottomright)?spw_none:special;
4711 1383826 tries = usewid/(offgrid ? 8 : 16);
4712
4713
2/2
✓ Branch 0 taken 1168843 times.
✓ Branch 1 taken 1384476 times.
2553319 for ( ; tries > 0; --tries )
4714 {
4715
2/2
✓ Branch 0 taken 211888 times.
✓ Branch 1 taken 1172588 times.
1384476 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4716 1384476 try_x += (offgrid ? 8 : 16);
4717
2/2
✓ Branch 0 taken 1169493 times.
✓ Branch 1 taken 214983 times.
1384476 if (!ok) break;
4718 1169493 }
4719
2/2
✓ Branch 0 taken 1168843 times.
✓ Branch 1 taken 214983 times.
1383826 if(!ok) break;
4720
1/2
✓ Branch 0 taken 1168843 times.
✗ Branch 1 not taken.
1168843 if((usewid%16)>0) //Uneven width
4721 {
4722 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4723 }
4724 1168843 break;
4725 }
4726 case 12:
4727 case down:
4728 {
4729
4/4
✓ Branch 0 taken 194058 times.
✓ Branch 1 taken 962705 times.
✓ Branch 2 taken 193332 times.
✓ Branch 3 taken 726 times.
1156763 if(enemycanfall(id) && isSideViewGravity())
4730 726 return false;
4731
4732 1156037 dy = dy2+s;
4733 1156037 tries = usewid/(offgrid ? 8 : 16);
4734
2/2
✓ Branch 0 taken 935910 times.
✓ Branch 1 taken 1156821 times.
2092731 for ( ; tries > 0; --tries )
4735 {
4736
3/4
✓ Branch 0 taken 218891 times.
✓ Branch 1 taken 937930 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 937930 times.
1156821 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4737 1156821 try_x += (offgrid ? 8 : 16);
4738
2/2
✓ Branch 0 taken 936694 times.
✓ Branch 1 taken 220127 times.
1156821 if (!ok) break;
4739 936694 }
4740
2/2
✓ Branch 0 taken 935910 times.
✓ Branch 1 taken 220127 times.
1156037 if(!ok) break;
4741
1/2
✓ Branch 0 taken 935910 times.
✗ Branch 1 not taken.
935910 if((usewid%16)>0) //Uneven width
4742 {
4743 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4744 }
4745 935910 break;
4746 }
4747 case 14:
4748 case left:
4749 {
4750 1279152 dx = dx1-s;
4751 1279152 sv = ((isSideViewGravity())?7:0);
4752
4/4
✓ Branch 0 taken 1278529 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1883 times.
✓ Branch 3 taken 1276646 times.
1279152 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4753 1279152 tries = usehei/(offgrid ? 8 : 16);
4754
2/2
✓ Branch 0 taken 1069947 times.
✓ Branch 1 taken 1280069 times.
2350016 for ( ; tries > 0; --tries )
4755 {
4756
2/2
✓ Branch 0 taken 207643 times.
✓ Branch 1 taken 1072426 times.
1280069 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4757 1280069 try_y += (offgrid ? 8 : 16);
4758
2/2
✓ Branch 0 taken 1070864 times.
✓ Branch 1 taken 209205 times.
1280069 if (!ok) break;
4759 1070864 }
4760
2/2
✓ Branch 0 taken 1069947 times.
✓ Branch 1 taken 209205 times.
1279152 if(!ok) break;
4761
1/2
✓ Branch 0 taken 1069947 times.
✗ Branch 1 not taken.
1069947 if((usehei%16)>0) //Uneven height
4762 {
4763 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4764 }
4765 1069947 break;
4766 }
4767 case 10:
4768 case right:
4769 {
4770 1269730 dx = dx2+s;
4771 1269730 sv = ((isSideViewGravity())?7:0);
4772 1269730 tries = usehei/(offgrid ? 8 : 16);
4773
2/2
✓ Branch 0 taken 1073347 times.
✓ Branch 1 taken 1270624 times.
2343971 for ( ; tries > 0; --tries )
4774 {
4775
3/4
✓ Branch 0 taken 194718 times.
✓ Branch 1 taken 1075906 times.
✓ Branch 2 taken 1075906 times.
✗ Branch 3 not taken.
1270624 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4776 1270624 try_y += (offgrid ? 8 : 16);
4777
2/2
✓ Branch 0 taken 1074241 times.
✓ Branch 1 taken 196383 times.
1270624 if (!ok) break;
4778 1074241 }
4779
2/2
✓ Branch 0 taken 1073347 times.
✓ Branch 1 taken 196383 times.
1269730 if(!ok) break;
4780
2/2
✓ Branch 0 taken 1073327 times.
✓ Branch 1 taken 20 times.
1073347 if((usehei%16)>0) //Uneven height
4781 {
4782
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4783 20 }
4784 1073347 break;
4785 }
4786 case 9:
4787 case r_up:
4788 {
4789 558497 dx = dx2+s;
4790 558497 dy = dy1-s;
4791 558497 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4792 558497 sv = ((isSideViewGravity())?7:0);
4793
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 558497 times.
1099152 for ( ; tries_x > 0; --tries_x )
4794 {
4795 558497 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4796 558497 try_y = 0;
4797
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 558497 times.
1099152 for ( ; tries_y > 0; --tries_y )
4798 {
4799
4/4
✓ Branch 0 taken 550183 times.
✓ Branch 1 taken 8314 times.
✓ Branch 2 taken 544702 times.
✓ Branch 3 taken 5481 times.
1103199 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4800
2/2
✓ Branch 0 taken 2841 times.
✓ Branch 1 taken 541861 times.
544702 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4801 558497 try_y += (offgrid ? 8 : 16);
4802
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 17842 times.
558497 if (!ok) break;
4803 540655 }
4804
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 17842 times.
558497 if (!ok) break;
4805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 540655 times.
540655 if((usehei%16)>0) //Uneven height
4806 {
4807 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4808 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4809 }
4810 540655 try_x += (offgrid ? 8 : 16);
4811 540655 }
4812
2/2
✓ Branch 0 taken 540655 times.
✓ Branch 1 taken 17842 times.
558497 if(!ok) break;
4813
1/2
✓ Branch 0 taken 540655 times.
✗ Branch 1 not taken.
540655 if((usewid%16)>0) //Uneven width
4814 {
4815 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4816 try_y = 0;
4817 for ( ; tries_y > 0; --tries_y )
4818 {
4819 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4820 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4821 try_y += (offgrid ? 8 : 16);
4822 if (!ok) break;
4823 }
4824 if (!ok) break;
4825 if((usehei%16)>0) //Uneven height
4826 {
4827 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4828 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4829 }
4830 }
4831 540655 break;
4832 }
4833 case 11:
4834 case r_down:
4835 {
4836 666174 dx = dx2+s;
4837 666174 dx = dy2+s;
4838 666174 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4839 //sv = ((isSideViewGravity())?7:0);
4840
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 666174 times.
1316276 for ( ; tries_x > 0; --tries_x )
4841 {
4842 666174 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4843 666174 try_y = 0;
4844
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 666174 times.
1316276 for ( ; tries_y > 0; --tries_y )
4845 {
4846
4/4
✓ Branch 0 taken 664663 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 651762 times.
✓ Branch 3 taken 12901 times.
1317936 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4847
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 651598 times.
651762 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4848 666174 try_y += (offgrid ? 8 : 16);
4849
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 16072 times.
666174 if (!ok) break;
4850 650102 }
4851
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 16072 times.
666174 if (!ok) break;
4852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650102 times.
650102 if((usehei%16)>0) //Uneven height
4853 {
4854 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4855 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4856 }
4857 650102 try_x += (offgrid ? 8 : 16);
4858 650102 }
4859
2/2
✓ Branch 0 taken 650102 times.
✓ Branch 1 taken 16072 times.
666174 if(!ok) break;
4860
1/2
✓ Branch 0 taken 650102 times.
✗ Branch 1 not taken.
650102 if((usewid%16)>0) //Uneven width
4861 {
4862 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4863 try_y = 0;
4864 for ( ; tries_y > 0; --tries_y )
4865 {
4866 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4867 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4868 try_y += (offgrid ? 8 : 16);
4869 if (!ok) break;
4870 }
4871 if (!ok) break;
4872 if((usehei%16)>0) //Uneven height
4873 {
4874 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4875 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4876 }
4877 }
4878 650102 break;
4879 }
4880 case 13:
4881 case l_down:
4882 {
4883 625432 dx = dx1-s;
4884 625432 dy = dy2+s;
4885 625432 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4886 //sv = ((isSideViewGravity())?7:0);
4887
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 625432 times.
1233037 for ( ; tries_x > 0; --tries_x )
4888 {
4889 625432 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4890 625432 try_y = 0;
4891
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 625432 times.
1233037 for ( ; tries_y > 0; --tries_y )
4892 {
4893
4/4
✓ Branch 0 taken 613437 times.
✓ Branch 1 taken 11995 times.
✓ Branch 2 taken 609141 times.
✓ Branch 3 taken 4296 times.
1234573 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4894
2/2
✓ Branch 0 taken 1056 times.
✓ Branch 1 taken 608085 times.
609141 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4895 625432 try_y += (offgrid ? 8 : 16);
4896
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 17827 times.
625432 if (!ok) break;
4897 607605 }
4898
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 17827 times.
625432 if (!ok) break;
4899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 607605 times.
607605 if((usehei%16)>0) //Uneven height
4900 {
4901 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4902 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4903 }
4904 607605 try_x += (offgrid ? 8 : 16);
4905 607605 }
4906
2/2
✓ Branch 0 taken 607605 times.
✓ Branch 1 taken 17827 times.
625432 if(!ok) break;
4907
1/2
✓ Branch 0 taken 607605 times.
✗ Branch 1 not taken.
607605 if((usewid%16)>0) //Uneven width
4908 {
4909 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4910 try_y = 0;
4911 for ( ; tries_y > 0; --tries_y )
4912 {
4913 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4914 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4915 try_y += (offgrid ? 8 : 16);
4916 if (!ok) break;
4917 }
4918 if (!ok) break;
4919 if((usehei%16)>0) //Uneven height
4920 {
4921 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4922 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4923 }
4924 }
4925 607605 break;
4926 }
4927 case 15:
4928 case l_up:
4929 {
4930 584251 dx = dx1-s;
4931 584251 dy = dy1-s;
4932 584251 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4933 584251 sv = ((isSideViewGravity())?7:0);
4934
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 584251 times.
1151922 for ( ; tries_x > 0; --tries_x )
4935 {
4936 584251 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4937 584251 try_y = 0;
4938
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 584251 times.
1151922 for ( ; tries_y > 0; --tries_y )
4939 {
4940
4/4
✓ Branch 0 taken 575555 times.
✓ Branch 1 taken 8696 times.
✓ Branch 2 taken 571553 times.
✓ Branch 3 taken 4002 times.
1155804 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4941
2/2
✓ Branch 0 taken 2807 times.
✓ Branch 1 taken 568746 times.
571553 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4942 584251 try_y += (offgrid ? 8 : 16);
4943
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 16580 times.
584251 if (!ok) break;
4944 567671 }
4945
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 16580 times.
584251 if (!ok) break;
4946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 567671 times.
567671 if((usehei%16)>0) //Uneven height
4947 {
4948 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4949 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4950 }
4951 567671 try_x += (offgrid ? 8 : 16);
4952 567671 }
4953
2/2
✓ Branch 0 taken 567671 times.
✓ Branch 1 taken 16580 times.
584251 if(!ok) break;
4954
1/2
✓ Branch 0 taken 567671 times.
✗ Branch 1 not taken.
567671 if((usewid%16)>0) //Uneven width
4955 {
4956 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4957 try_y = 0;
4958 for ( ; tries_y > 0; --tries_y )
4959 {
4960 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4961 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4962 try_y += (offgrid ? 8 : 16);
4963 if (!ok) break;
4964 }
4965 if (!ok) break;
4966 if((usehei%16)>0) //Uneven height
4967 {
4968 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4969 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4970 }
4971 }
4972 567671 break;
4973 }
4974 default:
4975 120754 db=99;
4976 120754 return true;
4977 }
4978
4979 7523099 return ok;
4980 7645239 }
4981
4982
4983 4811826 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4984 {
4985
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 4811760 times.
4811826 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4986
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 4811760 times.
4811826 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4987
2/2
✓ Branch 0 taken 4811760 times.
✓ Branch 1 taken 66 times.
4811826 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4988
2/2
✓ Branch 0 taken 4811760 times.
✓ Branch 1 taken 66 times.
4811826 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4989 4811826 --usewid;
4990 4811826 --usehei;
4991 4811826 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4992 }
4993
4994 1310489 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
4995 {
4996 1310489 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
4997
4998
4/4
✓ Branch 0 taken 7284 times.
✓ Branch 1 taken 1303205 times.
✓ Branch 2 taken 5385 times.
✓ Branch 3 taken 1899 times.
1310489 if(special==spw_clipright&&ndir==right)
4999 {
5000 1899 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5001 1899 }
5002
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1310484 times.
1310489 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5003
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1310484 times.
1310489 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5004
1/2
✓ Branch 0 taken 1310489 times.
✗ Branch 1 not taken.
1310489 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5005
1/2
✓ Branch 0 taken 1310489 times.
✗ Branch 1 not taken.
1310489 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5006 1310489 --usewid;
5007 1310489 --usehei;
5008
2/2
✓ Branch 0 taken 760676 times.
✓ Branch 1 taken 549813 times.
1310489 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5009 }
5010
5011 144373 bool enemy::canmove(int32_t ndir, bool kb)
5012 {
5013 144373 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5014 }
5015
5016 // 8-directional
5017 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5018 {
5019 562 int32_t ndir=0;
5020
5021 // can move straight, check if it wants to turn
5022
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5023 {
5024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5025 {
5026 int32_t w = Lwpns.idFirst(wBait);
5027
5028 if(w>=0)
5029 {
5030 int32_t bx = Lwpns.spr(w)->x;
5031 int32_t by = Lwpns.spr(w)->y;
5032
5033 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5034
5035 if(abs(int32_t(y)-by)>14)
5036 {
5037 if(ndir>0) // Already left or right
5038 {
5039 // Making the diagonal directions
5040 ndir += (by<y) ? 2 : 4;
5041 }
5042 else
5043 {
5044 ndir = (by<y) ? up : down;
5045 }
5046 }
5047
5048 if(canmove(ndir,special,false))
5049 {
5050 dir=ndir;
5051 return;
5052 }
5053 }
5054 }
5055
5056 // Homing added.
5057
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5058 {
5059 ndir = lined_up(8,true);
5060
5061 if(ndir>=0 && canmove(ndir,special,false))
5062 {
5063 dir=ndir;
5064 }
5065
5066 return;
5067 }
5068
5069 549 int32_t r=zc_oldrand();
5070
5071
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5072 {
5073 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5074 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5075
5076
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5077 525 dir=ndir;
5078
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5079 19 dir=ndir2;
5080
5081
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5082 // due to numerous lost fractional components. -L
5083 {
5084 x.doFloor();
5085 y.doFloor();
5086 }
5087 549 }
5088
5089 549 return;
5090 }
5091
5092 // can't move straight, must turn
5093 13 int32_t i=0;
5094
5095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5096 {
5097 20 ndir=(zc_oldrand()&7)+8;
5098
5099
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5100 13 break;
5101 7 }
5102
5103
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5104 {
5105 for(ndir=8; ndir<16; ndir++)
5106 {
5107 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5108 goto ok;
5109 }
5110
5111 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5112 }
5113
5114 ok:
5115 13 dir=ndir;
5116 13 x.doFloor();
5117 13 y.doFloor();
5118 562 }
5119
5120 600279 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5121 {
5122 600279 int32_t ndir=0;
5123
5124 // can move straight, check if it wants to turn
5125
2/2
✓ Branch 0 taken 566220 times.
✓ Branch 1 taken 34059 times.
600279 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5126 {
5127
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 566013 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
566220 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5128 {
5129 101 int32_t i = Lwpns.idFirst(wBait);
5130
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5131 {
5132 weapon *w = (weapon*)Lwpns.spr(i);
5133 if (get_qr(qr_FIND_CLOSEST_BAIT))
5134 {
5135 int32_t currentrange;
5136 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5137 else currentrange = -1;
5138 int curid = i;
5139 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5140 for(; i<Lwpns.Count(); ++i)
5141 {
5142 weapon *lw = (weapon*)Lwpns.spr(i);
5143 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5144 {
5145 currentrange = distance(x, y, lw->x, lw->y);
5146 curid = i;
5147 }
5148 }
5149 i = curid;
5150 if (currentrange == -1) i = -1;
5151 }
5152 else
5153 {
5154 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5155 }
5156 if(i>=0)
5157 {
5158 int32_t bx = Lwpns.spr(i)->x;
5159 int32_t by = Lwpns.spr(i)->y;
5160
5161 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5162
5163 if(abs(int32_t(y)-by)>14)
5164 {
5165 if(ndir>0) // Already left or right
5166 {
5167 // Making the diagonal directions
5168 ndir += (by<y) ? 2 : 4;
5169 }
5170 else
5171 {
5172 ndir = (by<y) ? up : down;
5173 }
5174 }
5175 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5176 if(canmove(ndir,special,false))
5177 {
5178 dir=ndir;
5179 return;
5180 }
5181 }
5182 }
5183 101 }
5184
5185 // Homing added.
5186
4/4
✓ Branch 0 taken 29843 times.
✓ Branch 1 taken 536377 times.
✓ Branch 2 taken 15574 times.
✓ Branch 3 taken 14269 times.
566220 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5187 {
5188 14269 ndir = lined_up(8,true);
5189
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14269 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14269 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5190
4/4
✓ Branch 0 taken 9480 times.
✓ Branch 1 taken 4789 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5887 times.
14269 if(ndir>=0 && canmove(ndir,special,false))
5191 {
5192 5887 dir=ndir;
5193 5887 }
5194
5195 14269 return;
5196 }
5197
5198 551951 int32_t r=zc_oldrand();
5199
5200
4/4
✓ Branch 0 taken 347861 times.
✓ Branch 1 taken 204090 times.
✓ Branch 2 taken 183707 times.
✓ Branch 3 taken 164154 times.
551951 if(newrate>0 && !(r%newrate))
5201 {
5202 164154 ndir = ((dir+((r&64)?-1:1))&7)+8;
5203 164154 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5204
5205
2/2
✓ Branch 0 taken 158137 times.
✓ Branch 1 taken 6017 times.
164154 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5206 158137 dir=ndir;
5207
2/2
✓ Branch 0 taken 915 times.
✓ Branch 1 taken 5102 times.
6017 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5208 5102 dir=ndir2;
5209
5210
4/4
✓ Branch 0 taken 158137 times.
✓ Branch 1 taken 6017 times.
✓ Branch 2 taken 150795 times.
✓ Branch 3 taken 7342 times.
164154 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5211 // due to numerous lost fractional components. -L
5212 {
5213 7342 x.doFloor();
5214 7342 y.doFloor();
5215 7342 }
5216 164154 }
5217
5218 551951 return;
5219 }
5220
5221 // can't move straight, must turn
5222 34059 int32_t i=0;
5223
5224 // TODO: speed this up!
5225
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 64145 times.
64218 for(; i<32; i++) // Try random dir
5226 {
5227 64145 ndir=(zc_oldrand()&7)+8;
5228
5229
2/2
✓ Branch 0 taken 30159 times.
✓ Branch 1 taken 33986 times.
64145 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5230 33986 break;
5231 30159 }
5232
5233
2/2
✓ Branch 0 taken 33986 times.
✓ Branch 1 taken 73 times.
34115 if(i==32)
5234 {
5235
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 56 times.
541 for(ndir=8; ndir<16; ndir++)
5236 {
5237
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 17 times.
485 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5238 17 goto ok;
5239 468 }
5240
5241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5242 56 }
5243
5244 ok:
5245 34059 dir=ndir;
5246 34059 x.doFloor();
5247 34059 y.doFloor();
5248 600279 }
5249
5250 593804 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5251 {
5252 593804 newdir_8(newrate,newhoming,special,0,-8,15,15);
5253 593804 }
5254
5255 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5256 {
5257 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5258 562 }
5259
5260 // makes the enemy slide backwards when hit
5261 // sclk: first byte is clk, second byte is dir
5262 // makes the enemy slide backwards when hit
5263 // sclk: first byte is clk, second byte is dir
5264 16426906 int32_t enemy::slide()
5265 {
5266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16426906 times.
16426906 if(script_knockback_clk!=0) //scripted knockback
5267 {
5268 sclk = 0;
5269 return 1; //scripted knockback ran
5270 }
5271
5/6
✓ Branch 0 taken 112516 times.
✓ Branch 1 taken 16314390 times.
✓ Branch 2 taken 8816 times.
✓ Branch 3 taken 103700 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8816 times.
16426906 if(sclk==0 || (hp<=0 && !immortal))
5272 16323206 return 0;
5273
5274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103700 times.
103700 if(knockbackflags & FLAG_NOSLIDE)
5275 {
5276 sclk = 0;
5277 if(!OFFGRID_ENEMY)
5278 {
5279 //Fix to grid
5280 do_fix(x, 16, true);
5281 do_fix(y, 16, true);
5282 }
5283 return 0;
5284 }
5285
8/10
✓ Branch 0 taken 10496 times.
✓ Branch 1 taken 93204 times.
✓ Branch 2 taken 1240 times.
✓ Branch 3 taken 9256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1240 times.
✓ Branch 6 taken 7047 times.
✓ Branch 7 taken 2209 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1240 times.
103700 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5286 {
5287 2209 sclk=0;
5288 2209 return 0;
5289 }
5290
5291 101491 --sclk;
5292
5293
5/5
✓ Branch 0 taken 2215 times.
✓ Branch 1 taken 11704 times.
✓ Branch 2 taken 13482 times.
✓ Branch 3 taken 35799 times.
✓ Branch 4 taken 38291 times.
101491 switch(sclk>>8)
5294 {
5295 case up:
5296 {
5297
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 10614 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 11697 times.
11704 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5298 {
5299 7 sclk=0;
5300 7 return 0;
5301 }
5302
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 10607 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
11697 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5303
5304 11522 break;
5305 }
5306 case down:
5307 {
5308
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13480 times.
13482 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5309 {
5310 2 sclk=0;
5311 2 return 0;
5312 }
5313
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 12411 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
13480 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5314
5315 13334 break;
5316 }
5317 case left:
5318 {
5319
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 33445 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 35786 times.
35799 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5320 {
5321 13 sclk=0;
5322 13 return 0;
5323 }
5324
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 33432 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
35786 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5325
5326 35548 break;
5327 }
5328 case right:
5329 {
5330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38291 times.
38291 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5331 {
5332 sclk=0;
5333 return 0;
5334 }
5335
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 35003 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
38291 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5336 38021 break;
5337 }
5338 }
5339
5340 100640 int32_t move = knockbackSpeed;
5341
2/2
✓ Branch 0 taken 95201 times.
✓ Branch 1 taken 100640 times.
195841 while(move>0)
5342 {
5343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100640 times.
100640 int32_t thismove = zc_min(8, move);
5344 100640 move -= thismove;
5345 100640 hitdir = (sclk>>8);
5346
5/5
✓ Branch 0 taken 2215 times.
✓ Branch 1 taken 11522 times.
✓ Branch 2 taken 13334 times.
✓ Branch 3 taken 35548 times.
✓ Branch 4 taken 38021 times.
100640 switch(sclk>>8)
5347 {
5348 case up:
5349 11522 y-=thismove;
5350 11522 break;
5351
5352 case down:
5353 13334 y+=thismove;
5354 13334 break;
5355
5356 case left:
5357 35548 x-=thismove;
5358 35548 break;
5359
5360 case right:
5361 38021 x+=thismove;
5362 38021 break;
5363 }
5364
2/2
✓ Branch 0 taken 95201 times.
✓ Branch 1 taken 5439 times.
100640 if(!canmove(sclk>>8,(zfix)0,0,true))
5365 {
5366
3/3
✓ Branch 0 taken 2227 times.
✓ Branch 1 taken 3208 times.
✓ Branch 2 taken 4 times.
5439 switch(sclk>>8)
5367 {
5368 case up:
5369 case down:
5370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2227 times.
2227 if(y < 0)
5371 y = 0;
5372
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 1849 times.
2227 else if((int32_t(y)&15) > 7)
5373 378 y = TRUNCATE_TILE(int32_t(y)) + 16;
5374 else
5375 1849 y = TRUNCATE_TILE(int32_t(y));
5376
5377 2227 break;
5378
5379 case left:
5380 case right:
5381
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3167 times.
3208 if(x < 0)
5382 41 x = 0;
5383
2/2
✓ Branch 0 taken 909 times.
✓ Branch 1 taken 2258 times.
3167 else if((int32_t(x)&15) > 7)
5384 909 x = TRUNCATE_TILE(int32_t(x)) + 16;
5385 else
5386 2258 x = TRUNCATE_TILE(int32_t(x));
5387
5388 3208 break;
5389 }
5390
5391 5439 sclk=0;
5392 5439 clk3=0;
5393 5439 break;
5394 }
5395 }
5396
5397
2/2
✓ Branch 0 taken 92423 times.
✓ Branch 1 taken 8217 times.
100640 if((sclk&255)==0)
5398 {
5399 //hitdir = -1;
5400 8217 sclk=0;
5401 8217 }
5402 100640 return 2;
5403 16426906 }
5404
5405 bool enemy::can_slide()
5406 {
5407 if(sclk==0 || (hp<=0 && !immortal))
5408 return false;
5409
5410 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5411 {
5412 return false;
5413 }
5414
5415 return true;
5416 }
5417
5418 bool enemy::fslide()
5419 {
5420 if(sclk==0 || (hp<=0 && !immortal))
5421 return false;
5422
5423 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5424 {
5425 sclk=0;
5426 return false;
5427 }
5428
5429 --sclk;
5430
5431 switch(sclk>>8)
5432 {
5433 case up:
5434 if(y<=16)
5435 {
5436 sclk=0;
5437 return false;
5438 }
5439
5440 break;
5441
5442 case down:
5443 if(y>=world_h-16)
5444 {
5445 sclk=0;
5446 return false;
5447 }
5448
5449 break;
5450
5451 case left:
5452 if(x<=16)
5453 {
5454 sclk=0;
5455 return false;
5456 }
5457
5458 break;
5459
5460 case right:
5461 if(x>=world_w-16)
5462 {
5463 sclk=0;
5464 return false;
5465 }
5466
5467 break;
5468 }
5469 hitdir = (sclk>>8);
5470 switch(sclk>>8)
5471 {
5472 case up:
5473 y-=4;
5474 break;
5475
5476 case down:
5477 y+=4;
5478 break;
5479
5480 case left:
5481 x-=4;
5482 break;
5483
5484 case right:
5485 x+=4;
5486 break;
5487 }
5488
5489 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5490 {
5491 switch(sclk>>8)
5492 {
5493 case up:
5494 case down:
5495 if((int32_t(y)&15) > 7)
5496 y = TRUNCATE_TILE(int32_t(y)) + 16;
5497 else
5498 y = TRUNCATE_TILE(int32_t(y));
5499
5500 break;
5501
5502 case left:
5503 case right:
5504 if((int32_t(x)&15) > 7)
5505 x = TRUNCATE_TILE(int32_t(x)) + 16;
5506 else
5507 x = TRUNCATE_TILE(int32_t(x));
5508
5509 break;
5510 }
5511
5512 sclk=0;
5513 clk3=0;
5514 }
5515
5516 if((sclk&255)==0)
5517 sclk=0;
5518
5519 return true;
5520 }
5521
5522 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5523 {
5524 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5525 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5526 bool ret = sprite::knockback(time, dir, speed);
5527 if(ret) sclk = 0; //kill engine knockback if interrupted
5528 //! Perhaps also set hitdir here, if needed for timing? -Z
5529 return ret;
5530 }
5531
5532 39022607 bool enemy::runKnockback()
5533 {
5534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39022607 times.
39022607 if((script_knockback_clk&0xFF)==0)
5535 {
5536 39022607 script_knockback_clk = 0;
5537 39022607 return false;
5538 }
5539 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5540 {
5541 return false;
5542 }
5543 int32_t move = script_knockback_speed;
5544 int32_t kb_dir = script_knockback_clk>>8;
5545 --script_knockback_clk;
5546
5547 while(move>0)
5548 {
5549 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5550 move -= thismove;
5551 hitdir = kb_dir;
5552 switch(kb_dir)
5553 {
5554 case r_up:
5555 case l_up:
5556 case up:
5557 y-=thismove;
5558 break;
5559
5560 case r_down:
5561 case l_down:
5562 case down:
5563 y+=thismove;
5564 break;
5565 }
5566 switch(kb_dir)
5567 {
5568 case l_up:
5569 case l_down:
5570 case left:
5571 x-=thismove;
5572 break;
5573
5574 case r_up:
5575 case r_down:
5576 case right:
5577 x+=thismove;
5578 break;
5579 }
5580 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5581 {
5582 if(!canmove(kb_dir,(zfix)0,0,true))
5583 {
5584 script_knockback_clk=0;
5585 clk3=0;
5586 //Fix to grid
5587 switch(kb_dir)
5588 {
5589 case up:
5590 case down:
5591 break;
5592 default:
5593 if(x < 0)
5594 x = 0;
5595 else if((int32_t(x)&15) > 7)
5596 x = TRUNCATE_TILE(int32_t(x)) + 16;
5597 else
5598 x = TRUNCATE_TILE(int32_t(x));
5599 break;
5600 }
5601 switch(kb_dir)
5602 {
5603 case left:
5604 case right:
5605 break;
5606 default:
5607 if(y < 0)
5608 y = 0;
5609 else if((int32_t(y)&15) > 7)
5610 y = TRUNCATE_TILE(int32_t(y)) + 16;
5611 else
5612 y = TRUNCATE_TILE(int32_t(y));
5613 break;
5614 }
5615 break;
5616 }
5617 }
5618 else
5619 {
5620 if(!scr_canplace(x,y,0,true))
5621 {
5622 script_knockback_clk=0;
5623 clk3=0;
5624 //Fix to grid
5625 if (OFFGRID_ENEMY)
5626 {
5627 switch(kb_dir)
5628 {
5629 case up:
5630 case down:
5631 break;
5632 default:
5633 if(x < 0)
5634 x = 0;
5635 else if((int32_t(x)&7) > 3)
5636 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5637 else
5638 x = TRUNCATE_HALF_TILE(int32_t(x));
5639 break;
5640 }
5641 switch(kb_dir)
5642 {
5643 case left:
5644 case right:
5645 break;
5646 default:
5647 if(y < 0)
5648 y = 0;
5649 else if((int32_t(y)&7) > 3)
5650 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5651 else
5652 y = TRUNCATE_HALF_TILE(int32_t(y));
5653 break;
5654 }
5655 }
5656 else
5657 {
5658 switch(kb_dir)
5659 {
5660 case up:
5661 case down:
5662 break;
5663 default:
5664 if(x < 0)
5665 x = 0;
5666 else if((int32_t(x)&15) > 7)
5667 x = TRUNCATE_TILE(int32_t(x)) + 16;
5668 else
5669 x = TRUNCATE_TILE(int32_t(x));
5670 break;
5671 }
5672 switch(kb_dir)
5673 {
5674 case left:
5675 case right:
5676 break;
5677 default:
5678 if(y < 0)
5679 y = 0;
5680 else if((int32_t(y)&15) > 7)
5681 y = TRUNCATE_TILE(int32_t(y)) + 16;
5682 else
5683 y = TRUNCATE_TILE(int32_t(y));
5684 break;
5685 }
5686 }
5687 break;
5688 }
5689
5690 }
5691 }
5692 return true;
5693 39022607 }
5694 // changes enemy's direction, checking restrictions
5695 // rate: 0 = no random changes, 16 = always random change
5696 // homing: 0 = none, 256 = always
5697 // grumble 0 = none, 4 = strongest appetite
5698 543806 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5699 {
5700 543806 int32_t ndir=-1;
5701
5702
4/4
✓ Branch 0 taken 115116 times.
✓ Branch 1 taken 428690 times.
✓ Branch 2 taken 40416 times.
✓ Branch 3 taken 74700 times.
543806 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5703 {
5704 74700 int32_t i = Lwpns.idFirst(wBait);
5705
1/2
✓ Branch 0 taken 74700 times.
✗ Branch 1 not taken.
74700 if(i >= 0) //idfirst returns -1 if it can't find any
5706 {
5707 weapon *w = (weapon*)Lwpns.spr(i);
5708 if (get_qr(qr_FIND_CLOSEST_BAIT))
5709 {
5710 int32_t currentrange;
5711 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5712 else currentrange = -1;
5713 int curid = i;
5714 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5715 for(; i<Lwpns.Count(); ++i)
5716 {
5717 weapon *lw = (weapon*)Lwpns.spr(i);
5718 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5719 {
5720 currentrange = distance(x, y, lw->x, lw->y);
5721 curid = i;
5722 }
5723 }
5724 i = curid;
5725 if (currentrange == -1) i = -1;
5726 }
5727 else
5728 {
5729 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5730 }
5731 if (i >= 0)
5732 {
5733 int32_t bx = Lwpns.spr(i)->x;
5734 int32_t by = Lwpns.spr(i)->y;
5735
5736 if(abs(int32_t(y)-by)>14)
5737 {
5738 ndir = (by<y) ? up : down;
5739 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5740 if(canmove(ndir,special,false))
5741 {
5742 dir=ndir;
5743 return;
5744 }
5745 }
5746
5747 ndir = (bx<x) ? left : right;
5748 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5749 if(canmove(ndir,special,false))
5750 {
5751 dir=ndir;
5752 return;
5753 }
5754 }
5755 }
5756 74700 }
5757
5758
2/2
✓ Branch 0 taken 366111 times.
✓ Branch 1 taken 177695 times.
543806 if((zc_oldrand()&255)<abs(newhoming))
5759 {
5760 177695 ndir = lined_up(8,false);
5761
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177695 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5762
4/4
✓ Branch 0 taken 47587 times.
✓ Branch 1 taken 130108 times.
✓ Branch 2 taken 5915 times.
✓ Branch 3 taken 41672 times.
177695 if(ndir>=0 && canmove(ndir,special,false))
5763 {
5764 41672 dir=ndir;
5765 41672 return;
5766 }
5767 136023 }
5768
5769 502134 int32_t i=0;
5770
5771
2/2
✓ Branch 0 taken 3951 times.
✓ Branch 1 taken 1243488 times.
1247439 for(; i<32; i++)
5772 {
5773 1243488 int32_t r=zc_oldrand();
5774
5775
2/2
✓ Branch 0 taken 356725 times.
✓ Branch 1 taken 886763 times.
1243488 if((r&15)<newrate)
5776 356725 ndir=(r>>4)&3;
5777 else
5778 886763 ndir=dir;
5779
5780
2/2
✓ Branch 0 taken 745305 times.
✓ Branch 1 taken 498183 times.
1243488 if(canmove(ndir,special,false))
5781 498183 break;
5782 745305 }
5783
5784
2/2
✓ Branch 0 taken 498183 times.
✓ Branch 1 taken 3951 times.
502896 if(i==32)
5785 {
5786
2/2
✓ Branch 0 taken 9934 times.
✓ Branch 1 taken 762 times.
10696 for(ndir=0; ndir<4; ndir++)
5787 {
5788
2/2
✓ Branch 0 taken 6745 times.
✓ Branch 1 taken 3189 times.
9934 if(canmove(ndir,special,false))
5789 3189 goto ok;
5790 6745 }
5791
5792
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 702 times.
762 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5793 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5794 762 }
5795
5796 ok:
5797 502134 dir = ndir;
5798 543806 }
5799
5800 2822 void enemy::newdir()
5801 {
5802 2822 newdir(4,0,spw_none);
5803 2822 }
5804
5805 zfix enemy::distance_left()
5806 {
5807 int32_t a2=x.getInt();
5808 int32_t b2=y.getInt();
5809
5810 switch(dir)
5811 {
5812 case up:
5813 return (zfix)(b2&0xF);
5814
5815 case down:
5816 return (zfix)(16-(b2&0xF));
5817
5818 case left:
5819 return (zfix)(a2&0xF);
5820
5821 case right:
5822 return (zfix)(16-(a2&0xF));
5823 }
5824
5825 return (zfix)0;
5826 }
5827
5828 // keeps walking around
5829 397833 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5830 {
5831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 397833 times.
397833 if(slide())
5832 return;
5833
5834
8/12
✓ Branch 0 taken 393987 times.
✓ Branch 1 taken 3846 times.
✓ Branch 2 taken 393987 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 389427 times.
✓ Branch 5 taken 4560 times.
✓ Branch 6 taken 389427 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 389427 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 389427 times.
397833 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5835 8406 return;
5836
5837
2/2
✓ Branch 0 taken 26349 times.
✓ Branch 1 taken 363078 times.
389427 if(clk3<=0)
5838 {
5839 26349 fix_coords(true);
5840 26349 newdir(newrate,newhoming,special);
5841
5842
1/2
✓ Branch 0 taken 26349 times.
✗ Branch 1 not taken.
26349 if(step==0)
5843 clk3=0;
5844 else
5845 26349 clk3=int32_t(16.0/step);
5846 26349 }
5847
2/2
✓ Branch 0 taken 363029 times.
✓ Branch 1 taken 49 times.
363078 else if(scored)
5848 {
5849 49 dir^=1;
5850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5851 else clk3=32767;
5852 49 }
5853
5854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 389427 times.
389427 if (step != 0) --clk3;
5855 389427 move(step);
5856 397833 }
5857
5858 void enemy::constant_walk()
5859 {
5860 constant_walk(4,0,spw_none);
5861 }
5862
5863 43048 int32_t enemy::pos(int32_t newx,int32_t newy)
5864 {
5865 43048 return (newy<<8)+newx;
5866 }
5867
5868 // for variable step rates
5869 570827 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5870 {
5871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 570827 times.
570827 if(slide())
5872 return;
5873
5874
10/14
✓ Branch 0 taken 570827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 570827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 562132 times.
✓ Branch 5 taken 8695 times.
✓ Branch 6 taken 552858 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 496046 times.
✓ Branch 9 taken 56812 times.
✓ Branch 10 taken 496046 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 496046 times.
✗ Branch 13 not taken.
570827 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5875 74781 return;
5876
5877 496046 zfix dx = (zfix)0;
5878 496046 zfix dy = (zfix)0;
5879
5880
5/9
✓ Branch 0 taken 118413 times.
✓ Branch 1 taken 122486 times.
✓ Branch 2 taken 123941 times.
✓ Branch 3 taken 128998 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 2208 times.
496046 switch(dir)
5881 {
5882 case 8:
5883 case up:
5884 118413 dy-=step;
5885 118413 break;
5886
5887 case 12:
5888 case down:
5889 122486 dy+=step;
5890 122486 break;
5891
5892 case 14:
5893 case left:
5894 123941 dx-=step;
5895 123941 break;
5896
5897 case 10:
5898 case right:
5899 128998 dx+=step;
5900 128998 break;
5901
5902 case 15:
5903 case l_up:
5904 dx-=step;
5905 dy-=step;
5906 break;
5907
5908 case 9:
5909 case r_up:
5910 dx+=step;
5911 dy-=step;
5912 break;
5913
5914 case 13:
5915 case l_down:
5916 dx-=step;
5917 dy+=step;
5918 break;
5919
5920 case 11:
5921 case r_down:
5922 dx+=step;
5923 dy+=step;
5924 break;
5925 }
5926
5927
8/8
✓ Branch 0 taken 255737 times.
✓ Branch 1 taken 240309 times.
✓ Branch 2 taken 27253 times.
✓ Branch 3 taken 228484 times.
✓ Branch 4 taken 13974 times.
✓ Branch 5 taken 13279 times.
✓ Branch 6 taken 480251 times.
✓ Branch 7 taken 15795 times.
496046 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5928 482072 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5929 {
5930 15795 fix_coords();
5931 15795 newdir(newrate,newhoming,special);
5932 15795 clk3=pos(x,y);
5933 15795 }
5934
5935 496046 move(step);
5936 570827 }
5937
5938 // pauses for a while after it makes a complete move (to a new square)
5939 12789274 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5940 {
5941
4/4
✓ Branch 0 taken 85091 times.
✓ Branch 1 taken 12704183 times.
✓ Branch 2 taken 71149 times.
✓ Branch 3 taken 13942 times.
12789274 if(sclk && clk2)
5942 {
5943 13942 clk3=0;
5944 13942 }
5945
5946
11/14
✓ Branch 0 taken 12711505 times.
✓ Branch 1 taken 77769 times.
✓ Branch 2 taken 12711505 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12711505 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12242919 times.
✓ Branch 7 taken 468586 times.
✓ Branch 8 taken 12105170 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 12094281 times.
✓ Branch 11 taken 10889 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 12094281 times.
12789274 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5947 {
5948 694993 return;
5949 }
5950
5951
2/2
✓ Branch 0 taken 2228493 times.
✓ Branch 1 taken 9865788 times.
12094281 if(clk2>0)
5952 {
5953 2228493 --clk2;
5954 2228493 return;
5955 }
5956
5957
2/2
✓ Branch 0 taken 428146 times.
✓ Branch 1 taken 9437642 times.
9865788 if(clk3<=0)
5958 {
5959 428146 fix_coords(true);
5960 428146 newdir(newrate,newhoming,special);
5961 428146 clk3=int32_t(16.0/step);
5962
2/2
✓ Branch 0 taken 427949 times.
✓ Branch 1 taken 197 times.
428146 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 428146 times.
428146 if(clk2<0)
5964 {
5965 clk2=0;
5966 }
5967
2/2
✓ Branch 0 taken 57028 times.
✓ Branch 1 taken 371118 times.
428146 else if((zc_oldrand()&15)<newhrate)
5968 {
5969 57028 clk2=haltcnt;
5970 57028 return;
5971 }
5972 371118 }
5973
2/2
✓ Branch 0 taken 9434349 times.
✓ Branch 1 taken 3293 times.
9437642 else if(scored)
5974 {
5975 3293 dir^=1;
5976
5977
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3288 times.
3293 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5978 5 else clk3=32767;
5979 3293 }
5980
5981
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9731821 times.
9808760 if (step != 0) --clk3;
5982 9808760 move(step);
5983 12789274 }
5984
5985 // 8-directional movement, aligns to 8 pixels
5986 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5987 {
5988 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5989 return;
5990
5991 if(clk3<=0)
5992 {
5993 newdir_8(newrate,newhoming,special);
5994 clk3=int32_t(8.0/step);
5995 if (step == 0) clk3 = 32767;
5996 }
5997
5998 if (step != 0) --clk3;
5999 move(step);
6000 }
6001 // 8-directional movement, aligns to 8 pixels
6002 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6003 {
6004
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6005 return;
6006
6007
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6008 {
6009 16235 newdir_8(newrate,newhoming,special);
6010 16235 clk3=int32_t(8.0/step);
6011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6012 16235 }
6013
6014
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6015 242393 move(step);
6016 242393 }
6017
6018 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6019 {
6020 if(clk<0 || dying || stunclk || watch || frozenclock)
6021 return;
6022
6023 if(!canmove(dir,step,special,false))
6024 clk3=0;
6025
6026 if(clk2>0)
6027 {
6028 --clk2;
6029 return;
6030 }
6031
6032 if(clk3<=0)
6033 {
6034 newdir_8(newrate,newhoming,special);
6035 clk3=newclk;
6036
6037 if(clk2<0)
6038 {
6039 clk2=0;
6040 }
6041 else if((zc_oldrand()&15)<newhrate)
6042 {
6043 newdir_8(newrate,newhoming,special);
6044 clk2=haltcnt;
6045 return;
6046 }
6047 }
6048
6049 --clk3;
6050 move(step);
6051 }
6052
6053 // 8-directional movement, no alignment
6054 4872408 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6055 {
6056
9/12
✓ Branch 0 taken 4661743 times.
✓ Branch 1 taken 210665 times.
✓ Branch 2 taken 4661743 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4635122 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4624075 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4624075 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4624075 times.
4872408 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6057 248333 return;
6058
6059
2/2
✓ Branch 0 taken 4592191 times.
✓ Branch 1 taken 31884 times.
4624075 if(!canmove(dir,step,special,false))
6060 31884 clk3=0;
6061
6062
2/2
✓ Branch 0 taken 4046506 times.
✓ Branch 1 taken 577569 times.
4624075 if(clk3<=0)
6063 {
6064 577569 newdir_8(newrate,newhoming,special);
6065 577569 clk3=newclk;
6066 577569 }
6067
6068 4624075 --clk3;
6069 4624075 move(step);
6070 4872408 }
6071
6072 // same as above but with variable enemy size
6073 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6074 {
6075
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6076 1247 return;
6077
6078
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6079 1334 clk3=0;
6080
6081
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6082 {
6083 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6084 6475 clk3=newclk;
6085 6475 }
6086
6087 93316 --clk3;
6088 93316 move(step);
6089 94563 }
6090
6091 // the variable speed floater movement
6092 // ms is max speed
6093 // ss is step speed
6094 // s is step count
6095 // p is pause count
6096 // g is graduality :)
6097 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6098 4170490 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6099 {
6100 4170490 ++clk2;
6101 4170490 bool over_pit = overpit();
6102
6103
4/4
✓ Branch 0 taken 1127398 times.
✓ Branch 1 taken 3043092 times.
✓ Branch 2 taken 1127057 times.
✓ Branch 3 taken 341 times.
4170490 if(dmisc1 && over_pit) p = 0;
6104
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 58167 times.
✓ Branch 2 taken 1664287 times.
✓ Branch 3 taken 2309513 times.
✓ Branch 4 taken 138523 times.
4170490 switch(movestatus)
6105 {
6106 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6107 //! if the conditions prevent it, we jump back to case 2.
6108 case 0: // paused
6109
2/2
✓ Branch 0 taken 56695 times.
✓ Branch 1 taken 1472 times.
58167 if(clk2>=p)
6110 {
6111 1472 movestatus=1;
6112 1472 clk2=0;
6113 1472 }
6114
6115 58167 break;
6116
6117 case 1: // speeding up
6118
1/2
✓ Branch 0 taken 1664287 times.
✗ Branch 1 not taken.
1664287 if (s >= 0)
6119 {
6120
2/2
✓ Branch 0 taken 1652642 times.
✓ Branch 1 taken 11645 times.
1664287 if(clk2<g*s)
6121 {
6122
2/2
✓ Branch 0 taken 1546014 times.
✓ Branch 1 taken 106628 times.
1652642 if(!((clk2-1)%g))
6123 106628 step+=ss;
6124 1652642 }
6125 else
6126 {
6127 11645 movestatus=2;
6128 11645 clk2=0;
6129 }
6130 1664287 }
6131 else
6132 {
6133 if(step < ms)
6134 {
6135 if(!((clk2-1)%g))
6136 {
6137 step+=ss;
6138 if (step >= ms) step = ms;
6139 }
6140 }
6141 else
6142 {
6143 step = ms;
6144 movestatus=2;
6145 clk2=0;
6146 }
6147 }
6148
6149 1664287 break;
6150
6151 case 2: // normal
6152 2309513 step=ms;
6153
6154
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2309513 times.
✓ Branch 2 taken 495344 times.
✓ Branch 3 taken 1814169 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1814169 times.
✓ Branch 6 taken 1811852 times.
✓ Branch 7 taken 2317 times.
2309513 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6155 {
6156
1/2
✓ Branch 0 taken 2317 times.
✗ Branch 1 not taken.
2317 if (s >= 0) step=ss*s;
6157 else step=ms;
6158 2317 movestatus=3;
6159 2317 clk2=0;
6160 2317 }
6161
6162 2309513 break;
6163
6164 case 3: // slowing down
6165
1/2
✓ Branch 0 taken 138523 times.
✗ Branch 1 not taken.
138523 if (s >= 0)
6166 {
6167
2/2
✓ Branch 0 taken 136812 times.
✓ Branch 1 taken 1711 times.
138523 if(clk2<=g*s)
6168 {
6169 { //don't slow down over pits
6170
6171
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 136373 times.
136812 if(over_pit)
6172 {
6173
1/2
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
439 if(dmisc1)
6174 {
6175 step=ms;
6176 }
6177 439 }
6178 else //can slow down
6179 {
6180
4/4
✓ Branch 0 taken 8399 times.
✓ Branch 1 taken 127974 times.
✓ Branch 2 taken 8031 times.
✓ Branch 3 taken 368 times.
136373 if(!(clk2%g) && !dmisc1)
6181 8031 step-=ss;
6182 }
6183 }
6184
6185
6186 136812 }
6187 else
6188 {
6189 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6190 //this doesn't help keese, as they have a z of 0.
6191 //they always nee to run this check.
6192 {
6193
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1711 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1711 if(over_pit &&!dmisc1)
6194 {
6195 --clk2; //if over a pit, don't land, and revert clock change
6196 }
6197 else //can land safely
6198 {
6199 1711 movestatus=0;
6200
3/4
✓ Branch 0 taken 1128 times.
✓ Branch 1 taken 583 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1128 times.
1711 if(dmisc1&&!over_pit)
6201 1128 step=0;
6202 1711 clk2=0;
6203 }
6204 }
6205
6206 }
6207 138523 }
6208 else
6209 {
6210 if(step > 0)
6211 {
6212 if(over_pit)
6213 {
6214 if(dmisc1)
6215 {
6216 step=ms;
6217 }
6218 }
6219 else //can slow down
6220 {
6221 if(!(clk2%g))
6222 step-=ss;
6223 }
6224 }
6225 else
6226 {
6227 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6228 //this doesn't help keese, as they have a z of 0.
6229 //they always nee to run this check.
6230 if(over_pit)
6231 {
6232 step+=ss; //if over a pit, don't land, and revert clock change
6233 }
6234 else //can land safely
6235 {
6236 movestatus=0;
6237 step=0;
6238 clk2=0;
6239 }
6240 }
6241 }
6242
6243 138523 break;
6244 }
6245
6246
2/2
✓ Branch 0 taken 2318841 times.
✓ Branch 1 taken 1851649 times.
4170490 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6247 4170490 }
6248
6249 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6250 {
6251 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6252 }
6253
6254 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6255 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6256 949410 int32_t enemy::lined_up(int32_t range, bool dir8)
6257 {
6258 949410 int32_t lx = Hero.getX();
6259 949410 int32_t ly = Hero.getY();
6260
6261
2/2
✓ Branch 0 taken 40417 times.
✓ Branch 1 taken 908993 times.
949410 if(abs(lx-int32_t(x))<=range)
6262 {
6263
2/2
✓ Branch 0 taken 16864 times.
✓ Branch 1 taken 23553 times.
40417 if(ly<y)
6264 {
6265 16864 return up;
6266 }
6267
6268 23553 return down;
6269 }
6270
6271
2/2
✓ Branch 0 taken 58505 times.
✓ Branch 1 taken 850488 times.
908993 if(abs(ly-int32_t(y))<=range)
6272 {
6273
2/2
✓ Branch 0 taken 31464 times.
✓ Branch 1 taken 27041 times.
58505 if(lx<x)
6274 {
6275 31464 return left;
6276 }
6277
6278 27041 return right;
6279 }
6280
6281
2/2
✓ Branch 0 taken 169486 times.
✓ Branch 1 taken 681002 times.
850488 if(dir8)
6282 {
6283
2/2
✓ Branch 0 taken 256739 times.
✓ Branch 1 taken 424263 times.
681002 if(abs(lx-x)-abs(ly-y)<=range)
6284 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6285 {
6286
2/2
✓ Branch 0 taken 106856 times.
✓ Branch 1 taken 149883 times.
256739 if(ly<y)
6287 {
6288
2/2
✓ Branch 0 taken 57358 times.
✓ Branch 1 taken 49498 times.
106856 if(lx<x)
6289 {
6290 57358 return l_up;
6291 }
6292 else
6293 {
6294 49498 return r_up;
6295 }
6296 }
6297 else
6298 {
6299
2/2
✓ Branch 0 taken 77422 times.
✓ Branch 1 taken 72461 times.
149883 if(lx<x)
6300 {
6301 72461 return l_down;
6302 }
6303 else
6304 {
6305 77422 return r_down;
6306 }
6307 }
6308 }
6309 424263 }
6310
6311 593749 return -1;
6312 949410 }
6313
6314 // returns true if Hero is within 'range' pixels of the enemy
6315 27887 bool enemy::HeroInRange(int32_t range)
6316 {
6317 27887 int32_t lx = Hero.getX();
6318 27887 int32_t ly = Hero.getY();
6319
2/2
✓ Branch 0 taken 22778 times.
✓ Branch 1 taken 5109 times.
27887 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6320 }
6321
6322 // place the enemy in line with Hero (red wizzrobes)
6323 4899 void enemy::place_on_axis(bool floater, bool solid_ok)
6324 {
6325
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4312 times.
✓ Branch 2 taken 4355 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3768 times.
4899 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6326
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 4109 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3670 times.
4899 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6327 4899 int32_t pos2=zc_oldrand()%23;
6328 4899 int32_t tried=0;
6329 4899 bool last_resort,placed=false;
6330
6331
6332 4899 do
6333 {
6334
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 3127 times.
7587 if(pos2<14)
6335 {
6336 4460 x=(pos2<<4)+16;
6337 4460 y=ly;
6338 4460 }
6339 else
6340 {
6341 3127 x=lx;
6342 3127 y=((pos2-14)<<4)+16;
6343 }
6344
6345 // Don't commit to a last resort if position is out of bounds.
6346
6/6
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 6936 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6679 times.
7587 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6347
6348
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 4862 times.
✓ Branch 3 taken 1475 times.
7587 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6349 {
6350 // Red Wizzrobes should be able to appear on water, but not other
6351 // solid combos; however, they could appear on solid combos in 2.10,
6352 // and some quests depend on that.
6353
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6201 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 4899 times.
8542 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6354 8542 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6355 4899 placed=true;
6356 8542 }
6357
6358
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4725 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7413 if(!placed && tried>=22 && last_resort)
6359 {
6360 placed=true;
6361 }
6362
6363 7413 ++tried;
6364 7413 pos2=(pos2+3)%23;
6365
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4725 times.
7413 }
6366 7413 while(!placed);
6367
6368
2/2
✓ Branch 0 taken 2917 times.
✓ Branch 1 taken 1808 times.
4725 if(y==ly)
6369 2917 dir=(x<lx)?right:left;
6370 else
6371 1808 dir=(y<ly)?down:up;
6372
6373 4725 clk2=tried;
6374 4725 }
6375
6376 21479608 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6377 {
6378 21479608 int32_t t = o_tile;
6379 21479608 int32_t b = o_tile;
6380
6381 // Darknuts, but also Wizzrobes and Wallmasters
6382
3/4
✓ Branch 0 taken 8940679 times.
✓ Branch 1 taken 11462151 times.
✓ Branch 2 taken 1076778 times.
✗ Branch 3 not taken.
21479608 switch(type)
6383 {
6384 case eeWALK:
6385
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10956744 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
11462151 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6386 {
6387 367468 tile=s_tile;
6388 367468 t=s_tile;
6389 367468 b=s_tile;
6390 367468 }
6391
6392 11462151 break;
6393
6394 case eeTRAP:
6395
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 883212 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1076778 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6396 {
6397 193566 tile=s_tile;
6398 193566 t=s_tile;
6399 193566 b=s_tile;
6400 193566 }
6401
6402 1076778 break;
6403
6404 case eeSPINTILE:
6405 if(misc>=96 && do_animation)
6406 {
6407 tile=o_tile+frames*ndir;
6408 t=tile;
6409 }
6410
6411 break;
6412 }
6413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21479608 times.
21479608 if ( do_animation )
6414 {
6415
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 21282566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21015435 times.
21479608 if(ndir!=0) switch(frames)
6416 {
6417 case 2:
6418 267131 tiledir_small(dir,ndir==4);
6419 267131 break;
6420
6421 case 3:
6422 tiledir_three(dir);
6423 break;
6424
6425 case 4:
6426 21015435 tiledir(dir,ndir==4);
6427 21015435 break;
6428 21282566 }
6429
6430
2/2
✓ Branch 0 taken 11462151 times.
✓ Branch 1 taken 10017457 times.
21479608 if(type==eeWALK)
6431
6/6
✓ Branch 0 taken 11400377 times.
✓ Branch 1 taken 61774 times.
✓ Branch 2 taken 8646924 times.
✓ Branch 3 taken 2815227 times.
✓ Branch 4 taken 2799303 times.
✓ Branch 5 taken 15924 times.
11462151 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6432 else
6433 10017457 tile+=f4;
6434 21479608 }
6435 21479608 return b;
6436 }
6437
6438 void enemy::tiledir_three(int32_t ndir)
6439 {
6440 if ( !do_animation ) return;
6441 flip=0;
6442
6443 switch(ndir)
6444 {
6445 case right:
6446 tile+=3;
6447 [[fallthrough]];
6448
6449 case left:
6450 tile+=3;
6451 [[fallthrough]];
6452
6453 case down:
6454 tile+=3;
6455 [[fallthrough]];
6456
6457 case up:
6458 break;
6459 }
6460 }
6461
6462 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6463 {
6464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6465 267131 flip=0;
6466
6467
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6468 {
6469 case 8:
6470 case up:
6471 53829 break;
6472
6473 case 12:
6474 case down:
6475 54679 tile+=2;
6476 54679 break;
6477
6478 case 14:
6479 case left:
6480 67727 tile+=4;
6481 67727 break;
6482
6483 case 10:
6484 case right:
6485 71182 tile+=6;
6486 71182 break;
6487
6488 case 9:
6489 case r_up:
6490
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6491 5706 break;
6492
6493 tile+=10;
6494 break;
6495
6496 case 11:
6497 case r_down:
6498
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6499 5154 tile+=2;
6500 else
6501 tile+=14;
6502
6503 5154 break;
6504
6505 case 13:
6506 case l_down:
6507
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6508 4872 tile+=2;
6509 else
6510 tile+=12;
6511
6512 4872 break;
6513
6514 case 15:
6515 case l_up:
6516
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6517 3982 break;
6518
6519 tile+=8;
6520 break;
6521
6522 default:
6523 //dir=(zc_oldrand()*100)%8;
6524 //tiledir_small(dir);
6525 // flip=zc_oldrand()&3;
6526 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6527 break;
6528 }
6529 267131 }
6530
6531 24500538 void enemy::tiledir(int32_t ndir, bool fourdir)
6532 {
6533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24500538 times.
24500538 if ( !do_animation ) return;
6534 24500538 flip=0;
6535
6536
9/9
✓ Branch 0 taken 4758764 times.
✓ Branch 1 taken 4413322 times.
✓ Branch 2 taken 5718471 times.
✓ Branch 3 taken 5503275 times.
✓ Branch 4 taken 882607 times.
✓ Branch 5 taken 1091633 times.
✓ Branch 6 taken 1164932 times.
✓ Branch 7 taken 897860 times.
✓ Branch 8 taken 69674 times.
24500538 switch(ndir)
6537 {
6538 case 8:
6539 case up:
6540 4758764 break;
6541
6542 case 12:
6543 case down:
6544 4413322 tile+=4;
6545 4413322 break;
6546
6547 case 14:
6548 case left:
6549 5718471 tile+=8;
6550 5718471 break;
6551
6552 case 10:
6553 case right:
6554 5503275 tile+=12;
6555 5503275 break;
6556
6557 case 9:
6558 case r_up:
6559
2/2
✓ Branch 0 taken 91176 times.
✓ Branch 1 taken 791431 times.
882607 if(fourdir)
6560 91176 break;
6561 else
6562 791431 tile+=24;
6563
6564 791431 break;
6565
6566 case 11:
6567 case r_down:
6568
2/2
✓ Branch 0 taken 103341 times.
✓ Branch 1 taken 988292 times.
1091633 if(fourdir)
6569 103341 tile+=4;
6570 else
6571 988292 tile+=32;
6572
6573 1091633 break;
6574
6575 case 13:
6576 case l_down:
6577
2/2
✓ Branch 0 taken 107670 times.
✓ Branch 1 taken 1057262 times.
1164932 if(fourdir)
6578 107670 tile+=4;
6579 else
6580 1057262 tile+=28;
6581
6582 1164932 break;
6583
6584 case 15:
6585 case l_up:
6586
2/2
✓ Branch 0 taken 87227 times.
✓ Branch 1 taken 810633 times.
897860 if(fourdir)
6587 87227 break;
6588 else
6589 810633 tile+=20;
6590
6591 810633 break;
6592
6593 default:
6594 //dir=(zc_oldrand()*100)%8;
6595 //tiledir(dir);
6596 // flip=zc_oldrand()&3;
6597 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6598 69674 break;
6599 }
6600 24500538 }
6601
6602 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6603 {
6604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6605 3868 flip=0;
6606
6607
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6608 {
6609 case 8:
6610 case up:
6611 297 break;
6612
6613 case 12:
6614 case down:
6615 tile+=8;
6616 break;
6617
6618 case 14:
6619 case left:
6620 195 tile+=40;
6621 195 break;
6622
6623 case 10:
6624 case right:
6625 179 tile+=48;
6626 179 break;
6627
6628 case 9:
6629 case r_up:
6630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6631 break;
6632
6633 306 tile+=88;
6634 306 break;
6635
6636 case 11:
6637 case r_down:
6638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6639 tile+=8;
6640 else
6641 1235 tile+=128;
6642
6643 1235 break;
6644
6645 case 13:
6646 case l_down:
6647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6648 tile+=8;
6649 else
6650 1324 tile+=120;
6651
6652 1324 break;
6653
6654 case 15:
6655 case l_up:
6656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6657 break;
6658
6659 332 tile+=80;
6660 332 break;
6661
6662 default:
6663 //dir=(zc_oldrand()*100)%8;
6664 //tiledir_big(dir);
6665 // flip=zc_oldrand()&3;
6666 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6667 break;
6668 }
6669 3868 }
6670
6671 41612879 void enemy::update_enemy_frame()
6672 {
6673
4/4
✓ Branch 0 taken 41609652 times.
✓ Branch 1 taken 3227 times.
✓ Branch 2 taken 1416 times.
✓ Branch 3 taken 41608236 times.
41612879 if(fallclk||drownclk) return;
6674
2/2
✓ Branch 0 taken 41592762 times.
✓ Branch 1 taken 15474 times.
41608236 if (!do_animation)
6675 15474 return;
6676
6677
4/4
✓ Branch 0 taken 2981941 times.
✓ Branch 1 taken 38610821 times.
✓ Branch 2 taken 2976633 times.
✓ Branch 3 taken 5308 times.
41592762 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6678
6679
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
41592762 if(get_qr(qr_ANONE_NOANIM)
6680
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41592762 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
41592762 && anim == aNONE && type != eeGUY)
6681 return;
6682
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 41221386 times.
41592762 int32_t newfrate = zc_max(frate,4);
6683 41592762 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6684 41592762 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6685
2/2
✓ Branch 0 taken 31596468 times.
✓ Branch 1 taken 9996294 times.
41592762 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6686 41592762 tile = o_tile;
6687 41592762 int32_t basetile = o_tile;
6688 41592762 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6689 41592762 bool ignore_extend = false;
6690
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 209447 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 379205 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5128844 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 61143 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1525813 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 709864 times.
✓ Branch 22 taken 1694695 times.
✓ Branch 23 taken 1160883 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4365684 times.
✓ Branch 27 taken 7944541 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582937 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1851190 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 7487838 times.
✓ Branch 37 taken 882793 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 208231 times.
41592762 switch(anim)
6691 {
6692
6693 case aDONGO:
6694 {
6695 69324 int32_t fr = stunclk>0 ? 16 : 8;
6696
6697
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6698 {
6699 // bloated
6700
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6701 {
6702 case up:
6703 960 tile+=9;
6704 960 flip=0;
6705 960 xofs=0;
6706 960 dummy_int[1]=0; //no additional tiles
6707 960 break;
6708
6709 case down:
6710 960 tile+=7;
6711 960 flip=0;
6712 960 xofs=0;
6713 960 dummy_int[1]=0; //no additional tiles
6714 960 break;
6715
6716 case left:
6717 1664 flip=1;
6718 1664 tile+=4;
6719 1664 xofs=16;
6720 1664 dummy_int[1]=1; //second tile is next tile
6721 1664 break;
6722
6723 case right:
6724 896 flip=0;
6725 896 tile+=5;
6726 896 xofs=16;
6727 896 dummy_int[1]=-1; //second tile is previous tile
6728 896 break;
6729 }
6730 4480 }
6731
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6732 {
6733 // normal
6734
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6735 {
6736 case up:
6737 13652 tile+=8;
6738 13652 flip=(clk&fr)?1:0;
6739 13652 xofs=0;
6740 13652 dummy_int[1]=0; //no additional tiles
6741 13652 break;
6742
6743 case down:
6744 15374 tile+=6;
6745 15374 flip=(clk&fr)?1:0;
6746 15374 xofs=0;
6747 15374 dummy_int[1]=0; //no additional tiles
6748 15374 break;
6749
6750 case left:
6751 19615 flip=1;
6752 19615 tile+=(clk&fr)?2:0;
6753 19615 xofs=16;
6754 19615 dummy_int[1]=1; //second tile is next tile
6755 19615 break;
6756
6757 case right:
6758 15086 flip=0;
6759 15086 tile+=(clk&fr)?3:1;
6760 15086 xofs=16;
6761 15086 dummy_int[1]=-1; //second tile is next tile
6762 15086 break;
6763 }
6764 63727 }
6765 }
6766 69324 break;
6767
6768 case aNEWDONGO:
6769 {
6770 61143 int32_t fr4=0;
6771
6772
6/6
✓ Branch 0 taken 58987 times.
✓ Branch 1 taken 2156 times.
✓ Branch 2 taken 4704 times.
✓ Branch 3 taken 54283 times.
✓ Branch 4 taken 1568 times.
✓ Branch 5 taken 3136 times.
61143 if(!dying && clk2>0 && clk2<=64)
6773 {
6774 // bloated
6775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3136 times.
3136 if(clk2>=0)
6776 {
6777 3136 fr4=3;
6778 3136 }
6779
6780
2/2
✓ Branch 0 taken 735 times.
✓ Branch 1 taken 2401 times.
3136 if(clk2>=16)
6781 {
6782 2401 fr4=2;
6783 2401 }
6784
6785
2/2
✓ Branch 0 taken 1519 times.
✓ Branch 1 taken 1617 times.
3136 if(clk2>=32)
6786 {
6787 1617 fr4=1;
6788 1617 }
6789
6790
2/2
✓ Branch 0 taken 2303 times.
✓ Branch 1 taken 833 times.
3136 if(clk2>=48)
6791 {
6792 833 fr4=0;
6793 833 }
6794
6795
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 640 times.
✓ Branch 3 taken 832 times.
✓ Branch 4 taken 1344 times.
3136 switch(dir)
6796 {
6797 case up:
6798 320 xofs=0;
6799 320 tile+=8+fr4;
6800 320 dummy_int[1]=0; //no additional tiles
6801 320 break;
6802
6803 case down:
6804 640 xofs=0;
6805 640 tile+=12+fr4;
6806 640 dummy_int[1]=0; //no additional tiles
6807 640 break;
6808
6809 case left:
6810 832 tile+=29+(2*fr4);
6811 832 xofs=16;
6812 832 dummy_int[1]=-1; //second tile is previous tile
6813 832 break;
6814
6815 case right:
6816 1344 tile+=49+(2*fr4);
6817 1344 xofs=16;
6818 1344 dummy_int[1]=-1; //second tile is previous tile
6819 1344 break;
6820 }
6821 3136 }
6822
4/4
✓ Branch 0 taken 2156 times.
✓ Branch 1 taken 55851 times.
✓ Branch 2 taken 1136 times.
✓ Branch 3 taken 1020 times.
58007 else if(!dying || clk2>19)
6823 {
6824 // normal
6825
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 10376 times.
✓ Branch 2 taken 10945 times.
✓ Branch 3 taken 17524 times.
✓ Branch 4 taken 18142 times.
56987 switch(dir)
6826 {
6827 case up:
6828 10376 xofs=0;
6829 10376 tile+=((clk&12)>>2);
6830 10376 dummy_int[1]=0; //no additional tiles
6831 10376 break;
6832
6833 case down:
6834 10945 xofs=0;
6835 10945 tile+=4+((clk&12)>>2);
6836 10945 dummy_int[1]=0; //no additional tiles
6837 10945 break;
6838
6839 case left:
6840 17524 tile+=21+((clk&12)>>1);
6841 17524 xofs=16;
6842 17524 dummy_int[1]=-1; //second tile is previous tile
6843 17524 break;
6844
6845 case right:
6846 18142 flip=0;
6847 18142 tile+=41+((clk&12)>>1);
6848 18142 xofs=16;
6849 18142 dummy_int[1]=-1; //second tile is previous tile
6850 18142 break;
6851 }
6852 56987 }
6853 }
6854 61143 break;
6855
6856 case aDONGOBS:
6857 {
6858 38833 int32_t fr4=0;
6859
6860
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6861 {
6862 // bloated
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6864 {
6865 2688 fr4=3;
6866 2688 }
6867
6868
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6869 {
6870 2058 fr4=2;
6871 2058 }
6872
6873
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6874 {
6875 1386 fr4=1;
6876 1386 }
6877
6878
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6879 {
6880 714 fr4=0;
6881 714 }
6882
6883
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6884 {
6885 case up:
6886 256 tile+=28+fr4;
6887 256 yofs+=8;
6888 256 dummy_int[1]=-20; //second tile change
6889 256 dummy_int[2]=0; //new xofs change
6890 256 dummy_int[3]=-16; //new xofs change
6891 256 break;
6892
6893 case down:
6894 384 tile+=12+fr4;
6895 384 yofs-=8;
6896 384 dummy_int[1]=20; //second tile change
6897 384 dummy_int[2]=0; //new xofs change
6898 384 dummy_int[3]=16; //new xofs change
6899 384 break;
6900
6901 case left:
6902 1024 tile+=49+(2*fr4);
6903 1024 xofs+=8;
6904 1024 dummy_int[1]=-1; //second tile change
6905 1024 dummy_int[2]=-16; //new xofs change
6906 1024 dummy_int[3]=0; //new xofs change
6907 1024 break;
6908
6909 case right:
6910 1024 tile+=69+(2*fr4);
6911 1024 xofs+=8;
6912 1024 dummy_int[1]=-1; //second tile change
6913 1024 dummy_int[2]=-16; //new xofs change
6914 1024 dummy_int[3]=0; //new xofs change
6915 1024 break;
6916 }
6917 2688 }
6918
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6919 {
6920 // normal
6921
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6922 {
6923 case up:
6924 7136 tile+=20+((clk&24)>>3);
6925 7136 yofs+=8;
6926 7136 dummy_int[1]=-20; //second tile change
6927 7136 dummy_int[2]=0; //new xofs change
6928 7136 dummy_int[3]=-16; //new xofs change
6929 7136 break;
6930
6931 case down:
6932 6672 tile+=4+((clk&24)>>3);
6933 6672 yofs-=8;
6934 6672 dummy_int[1]=20; //second tile change
6935 6672 dummy_int[2]=0; //new xofs change
6936 6672 dummy_int[3]=16; //new xofs change
6937 6672 break;
6938
6939 case left:
6940 11075 xofs=-8;
6941 11075 tile+=40+((clk&24)>>2);
6942 11075 dummy_int[1]=1; //second tile change
6943 11075 dummy_int[2]=16; //new xofs change
6944 11075 dummy_int[3]=0; //new xofs change
6945 11075 break;
6946
6947 case right:
6948 10601 tile+=60+((clk&24)>>2);
6949 10601 xofs=-8;
6950 10601 dummy_int[1]=1; //second tile change
6951 10601 dummy_int[2]=16; //new xofs change
6952 10601 dummy_int[3]=0; //new xofs change
6953 10601 break;
6954 }
6955 35484 }
6956 }
6957 38833 break;
6958
6959 case aWIZZ:
6960 {
6961 // if(d->misc1)
6962
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6963 {
6964
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6965 {
6966 91127 ++tile;
6967 91127 }
6968 182184 }
6969 else
6970 {
6971
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6972 {
6973 136489 ++tile;
6974 136489 }
6975 }
6976
6977
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6978 {
6979 case 9:
6980 case 15:
6981 case up:
6982 76094 tile+=2;
6983 76094 break;
6984
6985 case down:
6986 76591 break;
6987
6988 case 13:
6989 case left:
6990 157108 flip=1;
6991 157108 break;
6992
6993 default:
6994 145581 flip=0;
6995 145581 break;
6996 }
6997 }
6998 455374 break;
6999
7000 case aNEWWIZZ:
7001 {
7002 1525813 tiledir(dir,true);
7003
7004 // if(d->misc1) //walking wizzrobe
7005
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 783389 times.
1525813 if(dmisc1) //walking wizzrobe
7006 {
7007
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7008 {
7009 369103 tile+=2;
7010 369103 }
7011
7012
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7013 {
7014 370339 tile+=1;
7015 370339 }
7016
7017
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7018 {
7019
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7020 {
7021 79162 tile+=40;
7022 79162 }
7023 742424 }
7024 742424 }
7025 else
7026 {
7027
4/4
✓ Branch 0 taken 716244 times.
✓ Branch 1 taken 67145 times.
✓ Branch 2 taken 168827 times.
✓ Branch 3 taken 547417 times.
783389 if(dummy_bool[1]||dummy_bool[2])
7028 {
7029 235972 tile+=20;
7030
7031
2/2
✓ Branch 0 taken 67136 times.
✓ Branch 1 taken 168836 times.
235972 if(dummy_bool[2])
7032 {
7033 168836 tile+=20;
7034 168836 }
7035 235972 }
7036
7037 783389 tile+=((frame>>1)&3);
7038 }
7039 }
7040 1525813 break;
7041
7042 case a3FRM:
7043 {
7044
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7045 }
7046 197042 break;
7047
7048 case a3FRM4DIR:
7049 {
7050 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7051 }
7052 break;
7053
7054 case aVIRE:
7055 {
7056
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7057 {
7058 29292 tile+=2;
7059 29292 }
7060
7061 128880 tile+=fx;
7062 }
7063 128880 break;
7064
7065 case aROPE:
7066 {
7067 220021 tile+=(1-fx);
7068 220021 flip = dir==left ? 1:0;
7069 }
7070 220021 break;
7071
7072 case aZORA:
7073 {
7074 int32_t dl;
7075
7076
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7077 {
7078 46739 dl=clk+5;
7079 46739 goto waves2;
7080 }
7081
7082
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7083
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7084 else
7085 {
7086 92458 dl=clk-36-66;
7087 waves2:
7088 139197 tile=((dl/11)&1)+s_tile;
7089 139197 basetile = s_tile;
7090 }
7091 }
7092 221637 break;
7093
7094 case aNEWZORA:
7095 {
7096 709864 f4=(clk/16)%4;
7097
7098 709864 tiledir(dir,true);
7099 int32_t dl;
7100
7101
4/4
✓ Branch 0 taken 502852 times.
✓ Branch 1 taken 207012 times.
✓ Branch 2 taken 257748 times.
✓ Branch 3 taken 245104 times.
709864 if((clk>35)&&(clk<36+67)) //surfaced
7102 {
7103
4/4
✓ Branch 0 taken 209494 times.
✓ Branch 1 taken 35610 times.
✓ Branch 2 taken 30292 times.
✓ Branch 3 taken 179202 times.
245104 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7104 {
7105 179202 tile+=80;
7106 179202 } //mouth closed
7107 else
7108 {
7109 65902 tile+=40;
7110 }
7111
7112 245104 tile+=f4;
7113 245104 }
7114 else
7115 {
7116
2/2
✓ Branch 0 taken 207012 times.
✓ Branch 1 taken 257748 times.
464760 if(clk<36)
7117 {
7118 207012 dl=clk+5;
7119 207012 }
7120 else
7121 {
7122 257748 dl=clk-36-66;
7123 }
7124
7125 464760 tile+=((dl/5)&3);
7126 }
7127 }
7128 709864 break;
7129
7130 case a4FRM4EYE:
7131 case a2FRM4EYE:
7132 case a4FRM8EYE:
7133 case a4FRM8EYEB: //big version
7134 case a4FRM4EYEB:
7135 {
7136 836734 tilerows = 2;
7137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7139 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7140 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7141 836734 int32_t lookat=zc_oldrand()&15;
7142
7143
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7144 {
7145 210774 lookat=l_down;
7146 210774 }
7147
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7148 {
7149 226850 lookat=down;
7150 226850 }
7151
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7152 {
7153 108837 lookat=r_down;
7154 108837 }
7155
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7156 {
7157 70395 lookat=right;
7158 70395 }
7159
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7160 {
7161 35067 lookat=r_up;
7162 35067 }
7163
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7164 {
7165 25436 lookat=up;
7166 25436 }
7167
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7168 {
7169 36803 lookat=l_up;
7170 36803 }
7171 else
7172 {
7173 122572 lookat=left;
7174 }
7175
7176 836734 int32_t dir2 = dir;
7177 836734 dir = lookat;
7178
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7179 else
7180 {
7181 tiledir_big(dir,(anim == a4FRM4EYEB));
7182 tile+=2*f4;
7183 ignore_extend = true;
7184 }
7185 836734 dir = dir2;
7186 }
7187 836734 break;
7188
7189 case aFLIP:
7190 {
7191 1694695 flip = f2&1;
7192 }
7193 1694695 break;
7194
7195 case a2FRM:
7196 {
7197 1160883 tile += (1-f2);
7198 }
7199 1160883 break;
7200
7201 case a2FRMB:
7202 {
7203 tile+= 2*(1-f2);
7204 ignore_extend = true;
7205 }
7206 break;
7207
7208 case a2FRM4DIR:
7209 {
7210 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7211 }
7212 267131 break;
7213
7214 case a4FRM4DIRF:
7215 {
7216 4365684 basetile = n_frame_n_dir(4,4,f4);
7217
7218
2/2
✓ Branch 0 taken 2886480 times.
✓ Branch 1 taken 1479204 times.
4365684 if(clk2>0) //stopped to fire
7219 {
7220 1479204 tile+=20;
7221
7222
2/2
✓ Branch 0 taken 744443 times.
✓ Branch 1 taken 734761 times.
1479204 if(clk2<17) //firing
7223 {
7224 734761 tile+=20;
7225 734761 }
7226 1479204 }
7227 }
7228 4365684 break;
7229
7230 case a4FRM4DIR:
7231 {
7232 7944541 basetile = n_frame_n_dir(4,4,f4);
7233 }
7234 7944541 break;
7235
7236 case a4FRM8DIRF:
7237 {
7238 tilerows = 2;
7239 basetile = n_frame_n_dir(4,8,f4);
7240
7241 if(clk2>0) //stopped to fire
7242 {
7243 tile+=40;
7244
7245 if(clk2<17) //firing
7246 {
7247 tile+=40;
7248 }
7249 }
7250 }
7251 break;
7252
7253 case a4FRM8DIRB:
7254 case a4FRM8DIRFB:
7255 {
7256 3868 tilerows = 2;
7257 3868 tiledir_big(dir,false);
7258 3868 tile+=2*f4;
7259
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7260 {
7261 tile+=80;
7262
7263 if(clk2<17) //firing
7264 {
7265 tile+=80;
7266 }
7267 }
7268 3868 ignore_extend = true;
7269 }
7270 3868 break;
7271
7272 case a4FRM4DIRB:
7273 case a4FRM4DIRFB:
7274 {
7275 tilerows = 2;
7276 tiledir_big(dir,true);
7277 tile+=2*f4;
7278 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7279 {
7280 tile+=40;
7281
7282 if(clk2<17) //firing
7283 {
7284 tile+=40;
7285 }
7286 }
7287 ignore_extend = true;
7288 }
7289 break;
7290
7291 case aOCTO:
7292 {
7293
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165651 times.
✓ Branch 4 taken 157227 times.
582937 switch(dir)
7294 {
7295 case up:
7296 122459 flip = 2;
7297 122459 break;
7298
7299 case down:
7300 133448 flip = 0;
7301 133448 break;
7302
7303 case left:
7304 165651 flip = 0;
7305 165651 tile += 2;
7306 165651 break;
7307
7308 case right:
7309 157227 flip = 1;
7310 157227 tile += 2;
7311 157227 break;
7312 }
7313
7314 582937 tile+=f2;
7315 }
7316 582937 break;
7317
7318 case aWALK:
7319 {
7320
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7321 {
7322 case up:
7323 248704 tile+=3;
7324 248704 flip = f2;
7325 248704 break;
7326
7327 case down:
7328 267165 tile+=2;
7329 267165 flip = f2;
7330 267165 break;
7331
7332 case left:
7333 331694 flip=1;
7334 331694 tile += f2;
7335 331694 break;
7336
7337 case right:
7338 325802 flip=0;
7339 325802 tile += f2;
7340 325802 break;
7341 }
7342 }
7343 1178979 break;
7344
7345 case aDWALK:
7346 {
7347
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7348 {
7349 tile=s_tile;
7350 basetile = s_tile;
7351 }
7352
7353
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7354 {
7355 case up:
7356 177728 tile+=2;
7357 177728 flip=f2;
7358 177728 break;
7359
7360 case down:
7361 185581 flip=0;
7362 185581 tile+=(1-f2);
7363 185581 break;
7364
7365 case left:
7366 260885 flip=1;
7367 260885 tile+=(3+f2);
7368 260885 break;
7369
7370 case right:
7371 255982 flip=0;
7372 255982 tile+=(3+f2);
7373 255982 break;
7374 }
7375 }
7376 880176 break;
7377
7378 case aTEK:
7379 {
7380
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7381 {
7382 79120 tile += f2;
7383 79120 }
7384
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7385 {
7386 66827 ++tile;
7387 66827 }
7388 }
7389 219096 break;
7390
7391 case aNEWTEK:
7392 {
7393
2/2
✓ Branch 0 taken 486344 times.
✓ Branch 1 taken 1364846 times.
1851190 if(step<0) //up
7394 {
7395
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 241422 times.
✓ Branch 2 taken 244922 times.
486344 switch(clk3)
7396 {
7397 case left:
7398 241422 flip=0;
7399 241422 tile+=20;
7400 241422 break;
7401
7402 case right:
7403 244922 flip=0;
7404 244922 tile+=24;
7405 244922 break;
7406 }
7407 486344 }
7408
2/2
✓ Branch 0 taken 55855 times.
✓ Branch 1 taken 1308991 times.
1364846 else if(step==0)
7409 {
7410
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 41297 times.
✓ Branch 2 taken 14558 times.
55855 switch(clk3)
7411 {
7412 case left:
7413 41297 flip=0;
7414 41297 tile+=8;
7415 41297 break;
7416
7417 case right:
7418 14558 flip=0;
7419 14558 tile+=12;
7420 14558 break;
7421 }
7422 55855 } //down
7423 else
7424 {
7425
3/3
✓ Branch 0 taken 109422 times.
✓ Branch 1 taken 602693 times.
✓ Branch 2 taken 596876 times.
1308991 switch(clk3)
7426 {
7427 case left:
7428 602693 flip=0;
7429 602693 tile+=28;
7430 602693 break;
7431
7432 case right:
7433 596876 flip=0;
7434 596876 tile+=32;
7435 596876 break;
7436 }
7437 }
7438
7439
2/2
✓ Branch 0 taken 1263790 times.
✓ Branch 1 taken 587400 times.
1851190 if(misc==0)
7440 {
7441 587400 tile+=f4;
7442 587400 }
7443
2/2
✓ Branch 0 taken 591200 times.
✓ Branch 1 taken 672590 times.
1263790 else if(misc!=1)
7444 {
7445 672590 tile+=2;
7446 672590 }
7447 }
7448 1851190 break;
7449
7450 case aARMOS:
7451 {
7452
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7453 {
7454 5401 tile += fx;
7455
7456
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7457 1197 tile += 2;
7458 5401 }
7459 }
7460 8628 break;
7461
7462 case aARMOS4:
7463 {
7464
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29180 times.
✓ Branch 2 taken 92750 times.
✓ Branch 3 taken 43787 times.
✓ Branch 4 taken 43280 times.
209447 switch(dir)
7465 {
7466 case up:
7467 29180 flip=0;
7468 29180 break;
7469
7470 case down:
7471 92750 flip=0;
7472 92750 tile+=4;
7473 92750 break;
7474
7475 case left:
7476 43787 flip=0;
7477 43787 tile+=8;
7478 43787 break;
7479
7480 case right:
7481 43280 flip=0;
7482 43280 tile+=12;
7483 43280 break;
7484 }
7485
7486
2/2
✓ Branch 0 taken 63277 times.
✓ Branch 1 taken 146170 times.
209447 if(!fading)
7487 {
7488 146170 tile+=f4;
7489 146170 }
7490 }
7491 209447 break;
7492
7493 case aGHINI:
7494 {
7495
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7496 {
7497 case 8:
7498 case 9:
7499 case up:
7500 28037 ++tile;
7501 28037 flip=0;
7502 28037 break;
7503
7504 case 15:
7505 452 ++tile;
7506 452 flip=1;
7507 452 break;
7508
7509 case 10:
7510 case 11:
7511 case right:
7512 32092 flip=1;
7513 32092 break;
7514
7515 default:
7516 72763 flip=0;
7517 72763 break;
7518 }
7519 }
7520 133344 break;
7521
7522 case a2FRMPOS:
7523 {
7524 1755010 tile+=posframe;
7525 }
7526 1755010 break;
7527
7528 case a4FRMPOS4DIR:
7529 {
7530 379205 basetile = n_frame_n_dir(4,4,0);
7531 // tile+=f2;
7532 379205 tile+=posframe;
7533 }
7534 379205 break;
7535
7536 case a4FRMPOS4DIRF:
7537 {
7538 1433 basetile = n_frame_n_dir(4,4,0);
7539
7540
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7541 {
7542 197 tile+=20;
7543
7544
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7545 {
7546 64 tile+=20;
7547 64 }
7548 197 }
7549
7550 // tile+=f2;
7551 1433 tile+=posframe;
7552 }
7553 1433 break;
7554
7555 case a4FRMPOS8DIR:
7556 {
7557 7487838 tilerows = 2;
7558 7487838 int32_t n = tile;
7559 7487838 basetile = n_frame_n_dir(4,8,0);
7560 // tile+=f2;
7561 7487838 tile+=posframe;
7562 }
7563 7487838 break;
7564
7565 case a4FRMPOS8DIRF:
7566 {
7567 tilerows = 2;
7568 basetile = n_frame_n_dir(4,8,0);
7569
7570 if(clk2>0) //stopped to fire
7571 {
7572 tile+=40;
7573
7574 if(clk2<17) //firing
7575 {
7576 tile+=40;
7577 }
7578 }
7579
7580 tile+=posframe;
7581 }
7582 break;
7583
7584 case aNEWLEV:
7585 {
7586 882793 tiledir(dir,true);
7587
7588
4/5
✓ Branch 0 taken 288692 times.
✓ Branch 1 taken 139520 times.
✓ Branch 2 taken 58900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 395681 times.
882793 switch(misc)
7589 {
7590 case -1:
7591 case 0:
7592 288692 return;
7593
7594 case 1:
7595
7596 // case 5: cs = d->misc2; break;
7597 case 5:
7598 139520 cs = dmisc2;
7599 139520 break;
7600
7601 case 2:
7602 case 4:
7603 58900 tile += 20;
7604 58900 break;
7605
7606 case 3:
7607 395681 tile += 40;
7608 395681 break;
7609 }
7610
7611 594101 tile+=f4;
7612 }
7613 594101 break;
7614
7615 case aLEV:
7616 {
7617 276997 f4 = ((clk/5)&1);
7618
7619
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7620 {
7621 case -1:
7622 case 0:
7623 127945 return;
7624
7625 case 1:
7626
7627 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7628 case 5:
7629 33336 tile += (f2) ? 1 : 0;
7630 33336 cs = dmisc2;
7631 33336 break;
7632
7633 case 2:
7634 case 4:
7635 14658 tile += 2;
7636 14658 break;
7637
7638 case 3:
7639 101058 tile += (f4) ? 4 : 3;
7640 101058 break;
7641 }
7642 }
7643 149052 break;
7644
7645 case aWALLM:
7646 {
7647
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7648 {
7649 139764 tile += f2;
7650 139764 }
7651 }
7652 140514 break;
7653
7654 case aNEWWALLM:
7655 {
7656 366633 int32_t tempdir=0;
7657
7658
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7659 {
7660 case 1:
7661 case 2:
7662 43340 tempdir=clk3;
7663 43340 break;
7664
7665 case 3:
7666 case 4:
7667 case 5:
7668 38855 tempdir=dir;
7669 38855 break;
7670
7671 case 6:
7672 case 7:
7673 8438 tempdir=clk3^1;
7674 8438 break;
7675 }
7676
7677 366633 tiledir(tempdir,true);
7678
7679
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7680 {
7681 364725 tile+=f4;
7682 364725 }
7683 }
7684 366633 break;
7685
7686 case a4FRMNODIR:
7687 {
7688 208231 tile+=f4;
7689 }
7690 208231 break;
7691
7692 } // switch(d->anim)
7693
7694 // flashing
7695 // if(d->flags & guy_flashing)
7696
2/2
✓ Branch 0 taken 40428576 times.
✓ Branch 1 taken 747549 times.
41176125 if(flags & guy_flashing)
7697 {
7698 747549 cs = (frame&3) + 6;
7699 747549 }
7700
7701
2/2
✓ Branch 0 taken 40749717 times.
✓ Branch 1 taken 426408 times.
41176125 if(flags&guy_transparent)
7702 {
7703 426408 drawstyle=1;
7704 426408 }
7705
7706 41176125 int32_t change = tile-basetile;
7707
7708
3/6
✓ Branch 0 taken 2100068 times.
✓ Branch 1 taken 39076057 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2100068 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
41176125 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7709 {
7710
2/2
✓ Branch 0 taken 1817749 times.
✓ Branch 1 taken 282319 times.
2100068 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7711 {
7712 1817749 tile=basetile+txsz*change;
7713 1817749 }
7714 else
7715 {
7716 282319 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7717 }
7718 2100068 }
7719 else
7720 {
7721 39076057 tile=basetile+change;
7722 }
7723 41612879 }
7724
7725 82778 int32_t enemy::wpnsfx(int32_t wpn)
7726 {
7727
3/3
✓ Branch 0 taken 22655 times.
✓ Branch 1 taken 41540 times.
✓ Branch 2 taken 18583 times.
82778 switch (wpn)
7728 {
7729 case wScript1:
7730 case wScript2:
7731 case wScript3:
7732 case wScript4:
7733 case wScript5:
7734 case wScript6:
7735 case wScript7:
7736 case wScript8:
7737 case wScript9:
7738 case wScript10: //sure why not
7739 case ewFireTrail:
7740 case ewFlame:
7741 case ewFlame2Trail:
7742 case ewFlame2:
7743 case ewWind:
7744 case ewMagic:
7745 case ewIce:
7746 22655 return firesfx;
7747
7748 case ewRock:
7749 case ewFireball2:
7750 case ewFireball:
7751
2/2
✓ Branch 0 taken 6082 times.
✓ Branch 1 taken 35458 times.
41540 if (get_qr(qr_MORESOUNDS)) return firesfx;
7752 35458 break;
7753 }
7754
7755 54041 return 0;
7756 82778 }
7757
7758 79108729 int32_t enemy::run_script(int32_t mode)
7759 {
7760 void push_ri();
7761 void pop_ri();
7762
7763
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 79108473 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
79108729 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7764
4/6
✓ Branch 0 taken 230366 times.
✓ Branch 1 taken 78878107 times.
✓ Branch 2 taken 230366 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 230366 times.
79108473 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7765 78878107 return RUNSCRIPT_OK;
7766 230366 auto scrty = *get_scrtype();
7767 230366 auto uid = getUID();
7768
1/2
✓ Branch 0 taken 230366 times.
✗ Branch 1 not taken.
230366 if(!FFCore.doscript(scrty,uid))
7769 return RUNSCRIPT_OK;
7770 230366 int32_t ret = RUNSCRIPT_OK;
7771 230366 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7772 230366 push_ri();
7773
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 111621 times.
✓ Branch 2 taken 118745 times.
230366 switch(mode)
7774 {
7775 case MODE_NORMAL:
7776 111621 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7777 111621 break;
7778
7779 case MODE_WAITDRAW:
7780
1/2
✓ Branch 0 taken 118745 times.
✗ Branch 1 not taken.
118745 if(waitdraw)
7781 {
7782 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7783 waitdraw = false;
7784 }
7785 118745 break;
7786 }
7787 230366 pop_ri();
7788 230366 return ret;
7789 79108729 }
7790 5247 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7791 {
7792 5247 return al_map_rgba(255,0,0,opacity);
7793 }
7794
7795 // good guys, fires, fairy, and other non-enemies
7796 // based on enemy class b/c guys in dungeons act sort of like enemies
7797 // also easier to manage all the guys this way
7798 2198 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7799 2198 {
7800 2198 mainguy=mg;
7801 2198 canfreeze=false;
7802 2198 dir=down;
7803
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2198 times.
✓ Branch 2 taken 2198 times.
✗ Branch 3 not taken.
2198 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7804 2198 hxofs=2;
7805 2198 hzsz=8;
7806 2198 hit_width=12;
7807 2198 hit_height=17;
7808
7809
10/12
✓ Branch 0 taken 2198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1433 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2198 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7810 {
7811 1938 superman = 1;
7812 1938 hxofs=1000;
7813 1938 }
7814 2198 }
7815
7816 945874 bool guy::animate(int32_t index)
7817 {
7818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945874 times.
945874 if(switch_hooked) return enemy::animate(index);
7819
6/6
✓ Branch 0 taken 545304 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 8309 times.
✓ Branch 3 taken 536995 times.
✓ Branch 4 taken 7096 times.
✓ Branch 5 taken 1213 times.
945874 if(mainguy && clk==0 && misc==0)
7820 {
7821 1213 setupscreen();
7822 1213 misc = 1;
7823 1213 }
7824
7825
4/4
✓ Branch 0 taken 545304 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 544974 times.
✓ Branch 3 taken 330 times.
945874 if(mainguy && fadeclk==0)
7826 330 return true;
7827
7828 945544 hp=256; // good guys never die...
7829
7830
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 944622 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
945544 if(hclk && !clk2)
7831 {
7832 // but if they get hit...
7833 16 ++clk2; // only do this once
7834
7835
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7836 {
7837 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7838 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7839 7 }
7840 16 }
7841
7842 945544 return enemy::animate(index);
7843 945874 }
7844
7845 949646 void guy::draw(BITMAP *dest)
7846 {
7847 949646 update_enemy_frame();
7848
7849
6/6
✓ Branch 0 taken 548867 times.
✓ Branch 1 taken 400779 times.
✓ Branch 2 taken 22911 times.
✓ Branch 3 taken 525956 times.
✓ Branch 4 taken 11064 times.
✓ Branch 5 taken 11847 times.
949646 if(!mainguy || fadeclk<0 || fadeclk&1)
7850 937799 enemy::draw(dest);
7851 949646 }
7852
7853 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7854 760 {
7855 760 clk4=0;
7856
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7857 // Spawn type
7858
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7859 {
7860 clk=0;
7861 superman = 1;
7862 fading=fade_flicker;
7863 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7864 dir=down;
7865
7866 if(!canmove(down,(zfix)8,spw_none,false))
7867 clk3=int32_t(13.0/step);
7868 }
7869
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7870 {
7871 84 clk=0;
7872 84 }
7873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7874 760 }
7875
7876 167472 bool eFire::animate(int32_t index)
7877 {
7878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7879
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7880
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7881 {
7882
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7883 {
7884 1 clk4=0;
7885 1 superman=0;
7886 1 fading=0;
7887
7888
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7889 removearmos(x,y);
7890
7891 1 clk2=0;
7892
7893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7894 {
7895 1 dir=0;
7896 1 y = TRUNCATE_TILE(y.getInt());
7897 1 }
7898
7899 1 return Dead(index);
7900 }
7901
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7902 removearmos(x,y);
7903 1715 }
7904
7905 167471 return enemy::animate(index);
7906 167472 }
7907
7908 351659 void eFire::draw(BITMAP *dest)
7909 {
7910 351659 update_enemy_frame();
7911 351659 enemy::draw(dest);
7912 351659 }
7913
7914 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7915 {
7916 415 int32_t wpnId = w->id;
7917 415 int32_t wpnDir = w->dir;
7918
7919
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7920 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7921 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7922 {
7923 shield = false;
7924 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7925
7926 if(get_qr(qr_BRKNSHLDTILES))
7927 o_tile=s_tile;
7928 }
7929
7930 415 int32_t ret = enemy::takehit(w,realweap);
7931 415 return ret;
7932 }
7933
7934 void eFire::break_shield()
7935 {
7936 if(!shield)
7937 return;
7938
7939 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7940 shield=false;
7941
7942 if(get_qr(qr_BRKNSHLDTILES))
7943 o_tile=s_tile;
7944 }
7945
7946 void eFire::repair_shield()
7947 {
7948 if (shield)
7949 return;
7950
7951 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7952 return;
7953
7954 shield = true;
7955
7956 if (get_qr(qr_BRKNSHLDTILES))
7957 {
7958 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7959 else o_tile = d->tile;
7960 }
7961 }
7962
7963 7780 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7964 7780 {
7965 7780 clk4=0;
7966
4/8
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7780 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7780 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7780 times.
✗ Branch 7 not taken.
7780 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7967
7968 // Spawn type
7969
2/4
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7780 times.
7780 if(flags & guy_fade_flicker)
7970 {
7971 clk=0;
7972 superman = 1;
7973 fading=fade_flicker;
7974 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7975 dir=down;
7976
7977 if(!canmove(down,(zfix)8,spw_none,false))
7978 clk3=int32_t(13.0/step);
7979 }
7980
3/4
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6587 times.
✓ Branch 3 taken 1193 times.
7780 else if(flags & guy_fade_instant)
7981 {
7982 1193 clk=0;
7983 1193 }
7984
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 7745 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
7780 if (SIZEflags != 0) init_size_flags();;
7985 7780 }
7986
7987 2069428 bool eOther::animate(int32_t index)
7988 {
7989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2069428 times.
2069428 if(switch_hooked) return enemy::animate(index);
7990
4/4
✓ Branch 0 taken 2067842 times.
✓ Branch 1 taken 1586 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 2067777 times.
2069428 if(fallclk||drownclk) return enemy::animate(index);
7991
2/2
✓ Branch 0 taken 2059241 times.
✓ Branch 1 taken 8536 times.
2067777 if(fading)
7992 {
7993
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8507 times.
8536 if(++clk4 > 60)
7994 {
7995 29 clk4=0;
7996 29 superman=0;
7997 29 fading=0;
7998
7999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 if(flags&guy_armos && z==0 && fakez==0)
8000 removearmos(x,y);
8001
8002 29 clk2=0;
8003
8004
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(!canmove(down,(zfix)8,spw_none,false))
8005 {
8006 2 dir=0;
8007 2 y = TRUNCATE_TILE(y.getInt());
8008 2 }
8009
8010 29 return Dead(index);
8011 }
8012
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8507 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8013 removearmos(x,y);
8014 8507 }
8015
8016 2067748 return enemy::animate(index);
8017 2069428 }
8018
8019 2202629 void eOther::draw(BITMAP *dest)
8020 {
8021 2202629 update_enemy_frame();
8022 2202629 enemy::draw(dest);
8023 2202629 }
8024
8025 15414 int32_t eOther::takehit(weapon *w, weapon* realweap)
8026 {
8027 15414 int32_t wpnId = w->id;
8028 15414 int32_t wpnDir = w->dir;
8029
8030
4/4
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 15323 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 75 times.
15414 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8031
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8032 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8033 {
8034 shield = false;
8035 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8036
8037 if(get_qr(qr_BRKNSHLDTILES))
8038 o_tile=s_tile;
8039 }
8040
8041 15414 int32_t ret = enemy::takehit(w,realweap);
8042 15414 return ret;
8043 }
8044
8045 3 void eOther::break_shield()
8046 {
8047
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!shield)
8048 return;
8049
8050 3 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8051 3 shield=false;
8052
8053
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_qr(qr_BRKNSHLDTILES))
8054 3 o_tile=s_tile;
8055 3 }
8056
8057 void eOther::repair_shield()
8058 {
8059 if (shield)
8060 return;
8061
8062 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8063 return;
8064
8065 shield = true;
8066
8067 if (get_qr(qr_BRKNSHLDTILES))
8068 {
8069 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8070 else o_tile = d->tile;
8071 }
8072 }
8073
8074 30 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8075 30 {
8076 30 clk4=0;
8077
4/8
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 30 times.
✗ Branch 7 not taken.
30 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8078
8079 // Spawn type
8080
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
30 if(flags & guy_fade_flicker)
8081 {
8082 clk=0;
8083 superman = 1;
8084 fading=fade_flicker;
8085 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8086 dir=down;
8087
8088 if(!canmove(down,(zfix)8,spw_none,false))
8089 clk3=int32_t(13.0/step);
8090 }
8091
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 else if(flags & guy_fade_instant)
8092 {
8093 clk=0;
8094 }
8095
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
30 if (SIZEflags != 0) init_size_flags();;
8096 30 }
8097
8098 33693 bool eScript::animate(int32_t index)
8099 {
8100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33693 times.
33693 if(switch_hooked) return enemy::animate(index);
8101
2/4
✓ Branch 0 taken 33693 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33693 times.
33693 if(fallclk||drownclk) return enemy::animate(index);
8102
1/2
✓ Branch 0 taken 33693 times.
✗ Branch 1 not taken.
33693 if(fading)
8103 {
8104 if(++clk4 > 60)
8105 {
8106 clk4=0;
8107 superman=0;
8108 fading=0;
8109
8110 if(flags&guy_armos && z==0 && fakez==0)
8111 removearmos(x,y);
8112
8113 clk2=0;
8114
8115 if(!canmove(down,(zfix)8,spw_none,false))
8116 {
8117 dir=0;
8118 y = TRUNCATE_TILE(y.getInt());
8119 }
8120
8121 return Dead(index);
8122 }
8123 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8124 removearmos(x,y);
8125 }
8126
8127 33693 return enemy::animate(index);
8128 33693 }
8129
8130 41448 void eScript::draw(BITMAP *dest)
8131 {
8132 41448 update_enemy_frame();
8133 41448 enemy::draw(dest);
8134 41448 }
8135
8136 4997 int32_t eScript::takehit(weapon *w, weapon* realweap)
8137 {
8138 4997 int32_t wpnId = w->id;
8139 4997 int32_t wpnDir = w->dir;
8140
8141
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4997 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4997 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8142 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8143 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8144 {
8145 shield = false;
8146 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8147
8148 if(get_qr(qr_BRKNSHLDTILES))
8149 o_tile=s_tile;
8150 }
8151
8152 4997 int32_t ret = enemy::takehit(w,realweap);
8153 4997 return ret;
8154 }
8155
8156 void eScript::break_shield()
8157 {
8158 if(!shield)
8159 return;
8160
8161 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8162 shield=false;
8163
8164 if(get_qr(qr_BRKNSHLDTILES))
8165 o_tile=s_tile;
8166 }
8167
8168 void eScript::repair_shield()
8169 {
8170 if (shield)
8171 return;
8172
8173 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8174 return;
8175
8176 shield = true;
8177
8178 if (get_qr(qr_BRKNSHLDTILES))
8179 {
8180 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8181 else o_tile = d->tile;
8182 }
8183 }
8184
8185
8186 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8187 {
8188 clk4=0;
8189 hyofs = -32768; //No hitbox initially.
8190 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8191
8192 // Spawn type
8193 if(flags & guy_fade_flicker)
8194 {
8195 clk=0;
8196 superman = 1;
8197 fading=fade_flicker;
8198 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8199 dir=down;
8200
8201 if(!canmove(down,(zfix)8,spw_none,false))
8202 clk3=int32_t(13.0/step);
8203 }
8204 else if(flags & guy_fade_instant)
8205 {
8206 clk=0;
8207 }
8208 if (SIZEflags != 0) init_size_flags();;
8209 }
8210
8211 bool eFriendly::animate(int32_t index)
8212 {
8213 if(switch_hooked) return enemy::animate(index);
8214 if(fallclk||drownclk) return enemy::animate(index);
8215 if(fading)
8216 {
8217 if(++clk4 > 60)
8218 {
8219 clk4=0;
8220 superman=0;
8221 fading=0;
8222
8223 if(flags&guy_armos && z==0 && fakez==0)
8224 removearmos(x,y);
8225
8226 clk2=0;
8227
8228 if(!canmove(down,(zfix)8,spw_none,false))
8229 {
8230 dir=0;
8231 y = TRUNCATE_TILE(y.getInt());
8232 }
8233
8234 return Dead(index);
8235 }
8236 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8237 removearmos(x,y);
8238 }
8239
8240 return enemy::animate(index);
8241 }
8242
8243 void eFriendly::draw(BITMAP *dest)
8244 {
8245 update_enemy_frame();
8246 enemy::draw(dest);
8247 }
8248
8249 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8250 {
8251 int32_t wpnId = w->id;
8252 int32_t wpnDir = w->dir;
8253
8254 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8255 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8256 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8257 {
8258 shield = false;
8259 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8260
8261 if(get_qr(qr_BRKNSHLDTILES))
8262 o_tile=s_tile;
8263 }
8264
8265 int32_t ret = enemy::takehit(w,realweap);
8266 return ret;
8267 }
8268
8269 void eFriendly::break_shield()
8270 {
8271 if(!shield)
8272 return;
8273
8274 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8275 shield=false;
8276
8277 if(get_qr(qr_BRKNSHLDTILES))
8278 o_tile=s_tile;
8279 }
8280
8281 void eFriendly::repair_shield()
8282 {
8283 if (shield)
8284 return;
8285
8286 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8287 return;
8288
8289 shield = true;
8290
8291 if (get_qr(qr_BRKNSHLDTILES))
8292 {
8293 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8294 else o_tile = d->tile;
8295 }
8296 }
8297
8298
8299 790429 void enemy::removearmos(int32_t ax,int32_t ay)
8300 {
8301
2/2
✓ Branch 0 taken 789407 times.
✓ Branch 1 taken 1022 times.
790429 if(did_armos)
8302 789407 return;
8303 1022 did_armos=true;
8304 1022 auto handle = activated_handle;
8305
8306
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 700 times.
1022 auto layer = handle ? handle->layer() : 0;
8307
3/4
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 700 times.
✓ Branch 2 taken 322 times.
✗ Branch 3 not taken.
1022 if (!handle || handle->is_rpos())
8308 1022 handle = get_rpos_handle_for_world_xy(ax, ay, layer);
8309 1022 mapscr* scr = handle->get_mapscr();
8310
8311 1384 auto [tx, ty] = handle->xy();
8312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1022 times.
1022 if (handle->is_rpos())
8313 {
8314 2044 tx = TRUNCATE_TILE(ax);
8315 2044 ty = TRUNCATE_TILE(ay);
8316 1022 }
8317
8318 1022 int32_t f = handle->sflag();
8319 1022 int32_t f2 = handle->cflag();
8320
8321
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 178 times.
1022 if (handle->ctype() != cARMOS)
8322 844 return;
8323
8324
8325
3/4
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 156 times.
178 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8326 {
8327 22 handle->set_data(scr->secretcombo[sSTAIRS]);
8328 22 handle->set_cset(scr->secretcset[sSTAIRS]);
8329 22 handle->set_sflag(scr->secretflag[sSTAIRS]);
8330 22 sfx(scr->secretsfx);
8331 22 }
8332 else
8333 {
8334 156 handle->set_data(scr->undercombo);
8335 156 handle->set_cset(scr->undercset);
8336 156 handle->set_sflag(0);
8337 }
8338
8339
3/4
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 175 times.
178 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8340 {
8341
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8342 {
8343 6 additem(tx,ty,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8344 3 sfx(scr->secretsfx);
8345 3 }
8346 3 }
8347
8348 534 putcombo(scrollbuf,tx,ty,handle->data(),handle->cset());
8349 790429 }
8350
8351 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8352 461 {
8353 461 fading=fade_flicker;
8354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8355 461 dir=12;
8356 461 movestatus=1;
8357
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8358 461 clk=0;
8359 461 clk4=0;
8360
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8361 461 }
8362
8363 117025 bool eGhini::animate(int32_t index)
8364 {
8365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8366
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8367
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8368 50 return Dead(index);
8369
8370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8371 {
8372
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8373 {
8374
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8375 54853 misc=2;
8376
8377
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8378 89752 removearmos(x,y);
8379 89752 }
8380
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8381 {
8382 425 misc=1;
8383 425 clk3=32;
8384 425 fading=0;
8385
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 285 times.
425 if (activated_handle)
8386 {
8387 140 activation_counters[activated_handle->layer()][activated_handle->id()] = 0;
8388 140 removearmos(x, y);
8389 140 }
8390 else
8391 {
8392 285 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8393
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if (rpos != rpos_t::None)
8394 {
8395 285 activation_counters[0][int(rpos)] = 0;
8396 285 removearmos(x,y);
8397 285 }
8398 }
8399 425 }
8400 116975 }
8401
8402 116975 clk4++;
8403
8404 116975 return enemy::animate(index);
8405 117025 }
8406
8407 238808 void eGhini::draw(BITMAP *dest)
8408 {
8409 238808 update_enemy_frame();
8410 238808 enemy::draw(dest);
8411 238808 }
8412
8413 2 void eGhini::kickbucket()
8414 {
8415 2 hp=-1000; // don't call death_sfx()
8416 2 }
8417
8418
2/4
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5303 times.
✗ Branch 3 not taken.
10606 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8419 5303 {
8420
1/2
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
5303 old_y=y;
8421 5303 dir=down;
8422 5303 misc=1;
8423 5303 clk=-15;
8424
8425
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2654 times.
5303 if(!BSZ)
8426
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8427
8428 // avoid divide by 0 errors
8429
1/2
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
5303 if(dmisc1 == 0)
8430 dmisc1 = 24;
8431
8432
1/2
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
5303 if(dmisc2 == 0)
8433 dmisc2 = 3;
8434
8435 //nets+760;
8436
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5303 if (SIZEflags != 0) init_size_flags();;
8437 5303 }
8438
8439 998422 static bool tek_combo_check(zfix tx, zfix ty)
8440 {
8441 // tektites treat the world edge as a no-go zone if the combo next to the edge is a no-go zone
8442 // otherwise, they'll do a separate bounce from the edge, which leads to a slightly different trajectory.
8443 998422 tx = vbound(tx, 0, world_w-1);
8444 998422 ty = vbound(ty, 0, world_h-1);
8445
4/4
✓ Branch 0 taken 996800 times.
✓ Branch 1 taken 1622 times.
✓ Branch 2 taken 996782 times.
✓ Branch 3 taken 18 times.
1995204 return COMBOTYPE(tx, ty) == cNOJUMPZONE || COMBOTYPE(tx, ty) == cNOENEMY ||
8446
3/4
✓ Branch 0 taken 996782 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 103 times.
✓ Branch 3 taken 996679 times.
996782 ispitfall(tx, ty) || MAPFLAG(tx, ty) == mfNOENEMY ||
8447 996679 MAPCOMBOFLAG(tx, ty) == mfNOENEMY;
8448 }
8449 1450693 bool eTektite::animate(int32_t index)
8450 {
8451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1450693 times.
1450693 if(switch_hooked) return enemy::animate(index);
8452
4/4
✓ Branch 0 taken 1439215 times.
✓ Branch 1 taken 11478 times.
✓ Branch 2 taken 11478 times.
✓ Branch 3 taken 1437953 times.
1450693 if(fallclk||drownclk) return enemy::animate(index);
8453
2/2
✓ Branch 0 taken 26967 times.
✓ Branch 1 taken 1410986 times.
1437953 if(dying)
8454 26967 return Dead(index);
8455
8456
2/2
✓ Branch 0 taken 1373549 times.
✓ Branch 1 taken 37437 times.
1410986 if(clk==0)
8457 {
8458 37437 removearmos(x,y);
8459 37437 }
8460
8461
2/2
✓ Branch 0 taken 1058532 times.
✓ Branch 1 taken 352454 times.
1410986 if(get_qr(qr_ENEMIESZAXIS))
8462 {
8463 352454 y=floor_y;
8464 352454 }
8465
8466
9/10
✓ Branch 0 taken 1294828 times.
✓ Branch 1 taken 116158 times.
✓ Branch 2 taken 1281264 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1281264 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1270088 times.
✓ Branch 8 taken 10820 times.
✓ Branch 9 taken 21996 times.
1410986 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8467 {
8468
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 424353 times.
✓ Branch 2 taken 348142 times.
✓ Branch 3 taken 519589 times.
1292084 switch(misc)
8469 {
8470 case 0: // normal
8471
2/2
✓ Branch 0 taken 413019 times.
✓ Branch 1 taken 11334 times.
424353 if (!zc::math::SafeMod(zc_oldrand(), dmisc1))
8472 {
8473 11334 misc=1;
8474 11334 clk2=32;
8475 11334 }
8476
8477 424353 break;
8478
8479 case 1: // waiting to pounce
8480
2/2
✓ Branch 0 taken 327278 times.
✓ Branch 1 taken 20864 times.
348142 if(--clk2<=0)
8481 {
8482 20864 int32_t r=zc_oldrand();
8483 20864 misc=2;
8484 20864 step=0-(zslongToFix(dstep*100)); // initial speed
8485 20864 clk3=(r&1)+2; // left or right
8486 20864 clk2start=clk2=(r&31)+10; // flight time
8487
8488
2/2
✓ Branch 0 taken 2445 times.
✓ Branch 1 taken 18419 times.
20864 if(y<32) clk2+=2; // make them come down from top of screen
8489
8490
2/2
✓ Branch 0 taken 4950 times.
✓ Branch 1 taken 15914 times.
20864 if(y>world_h-64) clk2-=2; // make them go back up
8491
8492 20864 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8493 20864 }
8494
8495 348142 break;
8496
8497 case 2: // in flight
8498 519589 move(step);
8499
8500
2/2
✓ Branch 0 taken 518420 times.
✓ Branch 1 taken 1169 times.
519589 if (tek_combo_check(x + 8, y + (step > 0 ? 16 : 0)))
8501 1169 step = 0 - step;
8502
8503
2/2
✓ Branch 0 taken 518961 times.
✓ Branch 1 taken 628 times.
519589 if (tek_combo_check(x + (clk3 == left ? 0 : 16), y + 8))
8504 628 clk3 ^= 1;
8505
8506 519589 --c;
8507
8508
4/4
✓ Branch 0 taken 173577 times.
✓ Branch 1 taken 346012 times.
✓ Branch 2 taken 344608 times.
✓ Branch 3 taken 174981 times.
519589 if(c<0 && step<zslongToFix(dstep*100))
8509 {
8510 174981 step+=zslongToFix(dmisc3*100);
8511 174981 }
8512
8513 519589 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8514
8515
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 518861 times.
519589 if(x<=16-nb) clk3=right;
8516
8517
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 518592 times.
519589 if(x>=world_w-32+nb) clk3=left;
8518
8519 519589 x += (clk3==left) ? -1 : 1;
8520
8521
4/4
✓ Branch 0 taken 29298 times.
✓ Branch 1 taken 490291 times.
✓ Branch 2 taken 10189 times.
✓ Branch 3 taken 480102 times.
519589 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8522 {
8523
4/4
✓ Branch 0 taken 1625 times.
✓ Branch 1 taken 17484 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 189 times.
39487 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8524 {
8525 189 step=0-step;
8526 189 y--;
8527 189 }
8528
2/2
✓ Branch 0 taken 5861 times.
✓ Branch 1 taken 13059 times.
18920 else if (zc::math::SafeMod(zc_oldrand(), dmisc2)) //land and wait
8529 {
8530 13059 clk=misc=0;
8531 13059 } //land and jump again
8532 else
8533 {
8534 5861 misc=1;
8535 5861 clk2=0;
8536 }
8537 19109 }
8538
8539 499211 break;
8540 } // switch
8541 1271706 }
8542
8543
4/4
✓ Branch 0 taken 352454 times.
✓ Branch 1 taken 1059794 times.
✓ Branch 2 taken 236998 times.
✓ Branch 3 taken 115456 times.
1412248 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8544 {
8545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115456 times.
115456 if (moveflags & move_use_fake_z)
8546 {
8547 int32_t tempy = floor_y;
8548 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8549 floor_y = y;
8550 y=tempy-fakez;
8551 old_y = y;
8552 }
8553 else
8554 {
8555 115456 int32_t tempy = floor_y;
8556
6/6
✓ Branch 0 taken 58103 times.
✓ Branch 1 taken 57353 times.
✓ Branch 2 taken 109249 times.
✓ Branch 3 taken 6207 times.
✓ Branch 4 taken 53394 times.
✓ Branch 5 taken 55855 times.
115456 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8557 115456 floor_y = y;
8558 115456 y=tempy-z;
8559 115456 old_y = y;
8560 }
8561 115456 }
8562
8563
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1398684 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1412248 if(stunclk && (clk&31)==1)
8564 10637 clk=0;
8565
8566 1412248 return enemy::animate(index);
8567 1439215 }
8568
8569 1004450 bool eTektite::can_drawshadow() const
8570 {
8571
5/6
✓ Branch 0 taken 633102 times.
✓ Branch 1 taken 371348 times.
✓ Branch 2 taken 633102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26121 times.
✓ Branch 5 taken 606981 times.
1004450 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8572 26121 return false;
8573
8574 978329 return enemy::can_drawshadow();
8575 1004450 }
8576 821032 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8577 {
8578
2/2
✓ Branch 0 taken 637614 times.
✓ Branch 1 taken 183418 times.
821032 if(!can_drawshadow())
8579 637614 return;
8580
8581 183418 int32_t tempy=yofs;
8582 183418 int32_t fdiv = frate/4;
8583
1/2
✓ Branch 0 taken 183418 times.
✗ Branch 1 not taken.
183418 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8584
1/2
✓ Branch 0 taken 183418 times.
✗ Branch 1 not taken.
183418 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8585 183418 efrate:((clk>=(frate>>1))?1:0);
8586 183418 flip = 0;
8587 183418 shadowtile = wpnsbuf[spr_shadow].tile;
8588
8589
1/2
✓ Branch 0 taken 183418 times.
✗ Branch 1 not taken.
183418 if(get_qr(qr_NEWENEMYTILES))
8590 {
8591
2/2
✓ Branch 0 taken 114485 times.
✓ Branch 1 taken 68933 times.
183418 if(misc==0)
8592 {
8593 68933 shadowtile+=f2;
8594 68933 }
8595
2/2
✓ Branch 0 taken 50403 times.
✓ Branch 1 taken 64082 times.
114485 else if(misc!=1)
8596 64082 shadowtile+=2;
8597 183418 }
8598 else
8599 {
8600 if(misc==0)
8601 {
8602 shadowtile += f2 ? 1 : 0;
8603 }
8604 else if(misc!=1)
8605 {
8606 ++shadowtile;
8607 }
8608 }
8609
8610 183418 yofs+=8;
8611
8612
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 183418 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
183418 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8613 {
8614 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8615 }
8616 183418 enemy::drawshadow(dest,translucent);
8617 183418 yofs=tempy;
8618 821032 }
8619
8620 2084918 void eTektite::draw(BITMAP *dest)
8621 {
8622 2084918 update_enemy_frame();
8623 2084918 enemy::draw(dest);
8624 2084918 }
8625
8626 736 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8627 736 {
8628
2/4
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
736 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8629 736 superman=1;
8630 736 dir=8;
8631 736 hxofs=1000;
8632 736 mainguy=false;
8633 736 count_enemy=false;
8634
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 736 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
736 if (SIZEflags != 0) init_size_flags();;
8635 736 }
8636
8637 280632 bool eItemFairy::animate(int32_t index)
8638 {
8639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280632 times.
280632 if(switch_hooked) return enemy::animate(index);
8640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280632 times.
280632 if(dying)
8641 return Dead(index);
8642
8643 //if(clk>32)
8644 280632 misc=1;
8645 280632 bool w=watch;
8646 280632 watch=false;
8647 280632 variable_walk_8(misc?3:0,0,8,spw_floater);
8648 280632 watch=w;
8649
8650
2/2
✓ Branch 0 taken 1521 times.
✓ Branch 1 taken 279111 times.
280632 if(clk==0)
8651 {
8652 1521 removearmos(x,y);
8653 1521 }
8654
8655 280632 return enemy::animate(index);
8656 280632 }
8657
8658 563612 void eItemFairy::draw(BITMAP *dest)
8659 {
8660 //these are here to bypass compiler warnings about unused arguments
8661 563612 dest=dest;
8662 563612 }
8663
8664 1833 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8665 1833 {
8666 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8667
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1833 times.
✓ Branch 2 taken 1833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1833 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1833 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1833 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1833 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1833 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1833 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1833 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1833 times.
✗ Branch 19 not taken.
1833 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8668 1833 dir=8;
8669 1833 movestatus=1;
8670 1833 clk=0;
8671
1/2
✓ Branch 0 taken 1833 times.
✗ Branch 1 not taken.
1833 step=0;
8672 //nets+720;
8673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1833 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1833 if (SIZEflags != 0) init_size_flags();;
8674 1833 }
8675
8676 522341 bool ePeahat::animate(int32_t index)
8677 {
8678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 522341 times.
522341 if(switch_hooked) return enemy::animate(index);
8679
2/4
✓ Branch 0 taken 522341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 522341 times.
522341 if(fallclk||drownclk) return enemy::animate(index);
8680
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 522263 times.
522341 if(slide())
8681 {
8682 78 update_current_screen();
8683 78 return false;
8684 }
8685
8686
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 521233 times.
522263 if(dying)
8687 1030 return Dead(index);
8688
8689
2/2
✓ Branch 0 taken 3095 times.
✓ Branch 1 taken 518138 times.
521233 if(clk==0)
8690 {
8691 3095 removearmos(x,y);
8692 3095 }
8693
8694
4/4
✓ Branch 0 taken 518115 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 254234 times.
✓ Branch 3 taken 263881 times.
521233 if(stunclk==0 && clk>96)
8695 263881 misc=1;
8696
8697
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 518831 times.
521233 if(!watch)
8698
2/2
✓ Branch 0 taken 172185 times.
✓ Branch 1 taken 346646 times.
518831 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16, dmisc17);
8699
8700
3/4
✓ Branch 0 taken 101744 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101744 times.
521233 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8701 {
8702
1/2
✓ Branch 0 taken 101744 times.
✗ Branch 1 not taken.
101744 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8703 101744 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8704 101744 }
8705
8706
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 518831 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
521233 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8707 1634 superman=0;
8708 else
8709
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 509788 times.
519599 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8710 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8711
2/2
✓ Branch 0 taken 266663 times.
✓ Branch 1 taken 254570 times.
521233 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8712 {
8713
2/2
✓ Branch 0 taken 263548 times.
✓ Branch 1 taken 3115 times.
266663 if ( stunclk ) --stunclk;
8714 266663 }
8715 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8716 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8717
8718
8719
2/2
✓ Branch 0 taken 520993 times.
✓ Branch 1 taken 240 times.
521233 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8720
8721 521233 return enemy::animate(index);
8722 522341 }
8723
8724 336394 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8725 {
8726 336394 flip = 0;
8727
2/2
✓ Branch 0 taken 252623 times.
✓ Branch 1 taken 83771 times.
336394 if(!can_drawshadow())
8728 252623 return;
8729 83771 int32_t tempy=yofs;
8730 83771 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8731
8732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83771 times.
83771 if(!get_qr(qr_ENEMIESZAXIS))
8733 {
8734 yofs+=8;
8735 yofs+=int32_t(step/zslongToFix(dstep*10));
8736 }
8737 83771 enemy::drawshadow(dest,translucent);
8738 83771 yofs=tempy;
8739 336394 }
8740
8741 1149824 void ePeahat::draw(BITMAP *dest)
8742 {
8743 1149824 update_enemy_frame();
8744 1149824 enemy::draw(dest);
8745 1149824 }
8746
8747 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8748 {
8749 4136 int32_t wpnId = w->id;
8750 4136 int32_t enemyHitWeapon = w->parentitem;
8751
8752
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8753 return 0;
8754
8755
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8756 // fire boomerang, for nailing peahats
8757
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8758 3343 return 0;
8759
8760 // Time for a kludge...
8761 793 int32_t s = superman;
8762 793 superman = 0;
8763 793 int32_t ret = enemy::takehit(w,realweap);
8764 793 superman = s;
8765
8766 // Anyway...
8767
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8768 {
8769 192 clk2=0;
8770 192 movestatus=0;
8771 192 misc=0;
8772 192 clk=0;
8773 192 step=0;
8774 192 }
8775
8776 793 return ret;
8777 4136 }
8778
8779 // auomatically kill off enemy (for rooms with ringleaders)
8780 void ePeahat::kickbucket()
8781 {
8782 hp=-1000; // don't call death_sfx()
8783 }
8784
8785 4434 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8786 4434 {
8787 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8788
2/2
✓ Branch 0 taken 2235 times.
✓ Branch 1 taken 2199 times.
4434 if(dmisc1==0)
8789 {
8790 2199 misc=-1; //Line of Sight leevers
8791 2199 clk-=16;
8792 2199 }
8793 4434 clk3 = 0;
8794 //nets+1460;
8795 4434 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8796 4434 submerged = false;
8797
1/4
✓ Branch 0 taken 4434 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4434 if (SIZEflags != 0) init_size_flags();;
8798 4434 }
8799
8800 2260 bool eLeever::isSubmerged() const
8801 {
8802 2260 return misc <= 0;
8803 }
8804
8805 1147511 bool eLeever::animate(int32_t index)
8806 {
8807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1147511 times.
1147511 if(switch_hooked) return enemy::animate(index);
8808
3/4
✓ Branch 0 taken 1146801 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1146801 times.
1147511 if(fallclk||drownclk)
8809 {
8810 710 return enemy::animate(index);
8811 }
8812
2/2
✓ Branch 0 taken 33572 times.
✓ Branch 1 taken 1113229 times.
1146801 if(dying)
8813 33572 return Dead(index);
8814
8815
2/2
✓ Branch 0 taken 1061638 times.
✓ Branch 1 taken 51591 times.
1113229 if(clk==0)
8816 {
8817 51591 removearmos(x,y);
8818 51591 }
8819
8820
4/4
✓ Branch 0 taken 925465 times.
✓ Branch 1 taken 187764 times.
✓ Branch 2 taken 7201 times.
✓ Branch 3 taken 918264 times.
1113229 if(clk>=0 && !slide())
8821 {
8822
2/2
✓ Branch 0 taken 347437 times.
✓ Branch 1 taken 570827 times.
918264 switch(dmisc1)
8823 {
8824 case 0: //line of sight
8825 case 2:
8826
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 126285 times.
✓ Branch 2 taken 50473 times.
✓ Branch 3 taken 36580 times.
✓ Branch 4 taken 16242 times.
✓ Branch 5 taken 106113 times.
✓ Branch 6 taken 4536 times.
✓ Branch 7 taken 7208 times.
347437 switch(misc) //is this leever active
8827 {
8828 case -1: //submerged
8829 {
8830
4/6
✓ Branch 0 taken 8208 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 8208 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8208 times.
126285 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8831
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 115986 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
126285 if((dmisc1==2)&&(zc_oldrand()&255))
8832 {
8833 10261 break;
8834 }
8835
8836 116024 int32_t active=0;
8837
8838
2/2
✓ Branch 0 taken 793931 times.
✓ Branch 1 taken 116024 times.
909955 for(int32_t i=0; i<guys.Count(); i++)
8839 {
8840
4/4
✓ Branch 0 taken 634947 times.
✓ Branch 1 taken 158984 times.
✓ Branch 2 taken 405682 times.
✓ Branch 3 taken 229265 times.
793931 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8841 {
8842 229265 ++active;
8843 229265 }
8844 793931 }
8845
8846
2/2
✓ Branch 0 taken 114100 times.
✓ Branch 1 taken 1924 times.
116024 if(active<((dmisc1==2)?1:2))
8847 {
8848 1924 misc=0; //activate this one
8849 1924 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8850 1924 }
8851 }
8852 116024 break;
8853
8854 case 0:
8855 {
8856
8857
4/6
✓ Branch 0 taken 13284 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 13284 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13284 times.
50473 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8858 {
8859 misc=1;
8860 clk2=0;
8861 }
8862
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 50415 times.
50473 else if (clk3<=0)
8863 {
8864 58 misc = -1;
8865 58 break;
8866 }
8867 50415 int32_t s=0;
8868
8869
2/2
✓ Branch 0 taken 279841 times.
✓ Branch 1 taken 50415 times.
330256 for(int32_t i=0; i<guys.Count(); i++)
8870 {
8871
4/4
✓ Branch 0 taken 167298 times.
✓ Branch 1 taken 112543 times.
✓ Branch 2 taken 159136 times.
✓ Branch 3 taken 8162 times.
279841 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8872 {
8873 8162 ++s;
8874 8162 }
8875 279841 }
8876
8877
2/2
✓ Branch 0 taken 8162 times.
✓ Branch 1 taken 42253 times.
50415 if(s>0)
8878 {
8879 8162 break;
8880 }
8881
8882 42253 int32_t d2=zc_oldrand()&1;
8883
8884
2/2
✓ Branch 0 taken 14692 times.
✓ Branch 1 taken 27561 times.
42253 if(HeroDir()>=left)
8885 {
8886 27561 d2+=2;
8887 27561 }
8888
8889
4/4
✓ Branch 0 taken 40761 times.
✓ Branch 1 taken 1492 times.
✓ Branch 2 taken 685 times.
✓ Branch 3 taken 40076 times.
42253 if(canplace(d2) || canplace(d2^1))
8890 {
8891 2177 misc=1;
8892 2177 clk2=0;
8893 2177 clk=0;
8894 2177 }
8895 }
8896 42253 break;
8897
8898 case 1:
8899
8900
7/8
✓ Branch 0 taken 34448 times.
✓ Branch 1 taken 2132 times.
✓ Branch 2 taken 4647 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 4647 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 4646 times.
36580 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
8901
8902 36580 break;
8903
8904 case 2:
8905
8906
7/8
✓ Branch 0 taken 14272 times.
✓ Branch 1 taken 1970 times.
✓ Branch 2 taken 1910 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1910 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1909 times.
16242 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
8907
8908 16242 break;
8909
8910 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
8911 case 3:
8912
8913
5/6
✓ Branch 0 taken 102524 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 102524 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 99797 times.
106113 if(stunclk || frozenclock || watch) break;
8914
8915
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 99654 times.
99797 if(scored) dir^=1;
8916
8917
2/2
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 99273 times.
99797 if(!canmove(dir,false)) misc=4;
8918 99273 else move(zslongToFix(dstep*100));
8919
8920 99797 break;
8921
8922 case 4:
8923
4/6
✓ Branch 0 taken 781 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 781 times.
4536 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
8924
2/2
✓ Branch 0 taken 4049 times.
✓ Branch 1 taken 487 times.
4536 if(--clk2<=16)
8925 {
8926 487 misc=5;
8927 487 clk=8;
8928 487 }
8929
8930 4536 break;
8931
8932 case 5:
8933
5/6
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1310 times.
7208 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
8934
2/2
✓ Branch 0 taken 6780 times.
✓ Branch 1 taken 428 times.
7208 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
8935
8936 7208 break;
8937 } // switch(misc)
8938
8939 347437 break;
8940
8941 default: //random
8942 // step=d->misc3/100.0;
8943
8944 570827 step=zslongToFix(dmisc3*100);
8945
5/6
✓ Branch 0 taken 97013 times.
✓ Branch 1 taken 473814 times.
✓ Branch 2 taken 97013 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✓ Branch 5 taken 96943 times.
570827 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
8946
3/6
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
70 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8947 {
8948
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if (clk2 < 48) clk2+=2;
8949
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if (clk2 >= 300) clk2-=2;
8950 70 }
8951
8952
2/2
✓ Branch 0 taken 75127 times.
✓ Branch 1 taken 495700 times.
570827 if(clk2<32) misc=1;
8953
2/2
✓ Branch 0 taken 37104 times.
✓ Branch 1 taken 458596 times.
495700 else if(clk2<48) misc=2;
8954
2/2
✓ Branch 0 taken 348113 times.
✓ Branch 1 taken 110483 times.
458596 else if(clk2<300)
8955 {
8956 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
8957 {
8958 fix_coords();
8959 }*/
8960 348113 misc=3;
8961 348113 step = zslongToFix(dstep*100);
8962 348113 }
8963
2/2
✓ Branch 0 taken 10512 times.
✓ Branch 1 taken 99971 times.
110483 else if(clk2<316) misc=2;
8964
2/2
✓ Branch 0 taken 51567 times.
✓ Branch 1 taken 48404 times.
99971 else if(clk2<412) misc=1;
8965
2/2
✓ Branch 0 taken 48074 times.
✓ Branch 1 taken 330 times.
48404 else if(clk2<540)
8966 {
8967 48074 misc=0;
8968 48074 step=0;
8969 48074 }
8970 330 else clk2=0;
8971
8972
2/2
✓ Branch 0 taken 568557 times.
✓ Branch 1 taken 2270 times.
570827 if(clk2==48) clk=0;
8973
8974 // variable_walk(d->rate, d->homing, 0);
8975 570827 variable_walk(rate, homing, 0);
8976 570827 } // switch(dmisc1)
8977 918264 }
8978
8979 1113229 hxofs=(misc>=2)?0:1000;
8980 1113229 return enemy::animate(index);
8981 1147511 }
8982
8983 83014 bool eLeever::canplace(int32_t d2)
8984 {
8985 83014 int32_t nx=HeroX();
8986 83014 int32_t ny=HeroY();
8987
8988
2/2
✓ Branch 0 taken 28840 times.
✓ Branch 1 taken 54174 times.
83014 if(d2<left) ny=TRUNCATE_TILE(ny);
8989 54174 else nx=TRUNCATE_TILE(nx);
8990
8991
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14347 times.
✓ Branch 2 taken 14493 times.
✓ Branch 3 taken 27073 times.
✓ Branch 4 taken 27101 times.
83014 switch(d2)
8992 {
8993 case up:
8994
2/2
✓ Branch 0 taken 14317 times.
✓ Branch 1 taken 30 times.
14347 ny-=((dmisc1==0||dmisc1==2)?32:48);
8995 14347 break;
8996
8997 case down:
8998
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14459 times.
14493 ny+=((dmisc1==0||dmisc1==2)?32:48);
8999
9000
4/4
✓ Branch 0 taken 10212 times.
✓ Branch 1 taken 4281 times.
✓ Branch 2 taken 10201 times.
✓ Branch 3 taken 11 times.
14493 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9001
9002 14493 break;
9003
9004 case left:
9005
2/2
✓ Branch 0 taken 26420 times.
✓ Branch 1 taken 653 times.
27073 nx-=((dmisc1==0||dmisc1==2)?32:48);
9006 27073 break;
9007
9008 case right:
9009
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 26455 times.
27101 nx+=((dmisc1==0||dmisc1==2)?32:48);
9010
9011
4/4
✓ Branch 0 taken 19994 times.
✓ Branch 1 taken 7107 times.
✓ Branch 2 taken 19392 times.
✓ Branch 3 taken 602 times.
27101 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9012
9013 27101 break;
9014 }
9015
9016
4/4
✓ Branch 0 taken 21099 times.
✓ Branch 1 taken 61915 times.
✓ Branch 2 taken 9435 times.
✓ Branch 3 taken 11664 times.
83014 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9017 71350 return false;
9018
9019
2/2
✓ Branch 0 taken 891 times.
✓ Branch 1 taken 10773 times.
11664 if(d2>=left)
9020
4/4
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 5694 times.
✓ Branch 2 taken 9487 times.
✓ Branch 3 taken 1286 times.
10773 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9021 9487 return false;
9022
9023 2177 x=nx;
9024 2177 y=ny;
9025 2177 dir=d2^1;
9026 2177 return true;
9027 83014 }
9028
9029 1160500 void eLeever::draw(BITMAP *dest)
9030 {
9031 // cs=d->cset;
9032 1160500 cs=dcset;
9033 1160500 update_enemy_frame();
9034
3/4
✓ Branch 0 taken 1159790 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1159790 times.
1160500 if(!fallclk&&!drownclk)
9035 {
9036
2/2
✓ Branch 0 taken 743153 times.
✓ Branch 1 taken 416637 times.
1159790 switch(misc)
9037 {
9038 case -1:
9039 case 0:
9040 416637 return;
9041 }
9042 743153 }
9043
9044 743863 enemy::draw(dest);
9045 1160500 }
9046
9047 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9048 998 {
9049 998 hashero=false;
9050 //nets+1000;
9051
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9052 998 }
9053
9054 504762 bool eWallM::animate(int32_t index)
9055 {
9056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9057
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9058 {
9059 return enemy::animate(index);
9060 }
9061
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9062 9856 return Dead(index);
9063
9064
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9065 {
9066 30976 removearmos(x,y);
9067 30976 }
9068
9069 494906 hxofs=1000;
9070
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9071 {
9072
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9073 {
9074 211789 int32_t wall=hero_on_wall();
9075 211789 int32_t wallm_cnt=0;
9076
9077
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9078
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->type==eeWALLM)
9079 {
9080 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9081
9082
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9083 {
9084 13366 ++wallm_cnt;
9085 13366 }
9086 1013091 }
9087
9088
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9089 {
9090 841 --wall;
9091 841 misc=1; //emerging from the wall?
9092 841 clk2=0;
9093 841 clk3=wall^1;
9094 841 wallm_load_clk=frame;
9095
9096
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9097 {
9098
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9099 91 dir=right;
9100 else
9101 423 dir=left;
9102 514 }
9103 else
9104 {
9105
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9106 66 dir=down;
9107 else
9108 261 dir=up;
9109 }
9110
9111
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9112 {
9113 case up:
9114 231 y=0;
9115 231 break;
9116
9117 case down:
9118 283 y=160;
9119 283 break;
9120
9121 case left:
9122 223 x=0;
9123 223 break;
9124
9125 case right:
9126 104 x=240;
9127 104 break;
9128 }
9129
9130
9131
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9132 {
9133 case up:
9134 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9135 261 flip=wall&1;
9136 261 break;
9137
9138 case down:
9139 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9140 66 flip=((wall&1)^1)+2;
9141 66 break;
9142
9143 case left:
9144 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9145 423 flip=(wall==up?2:0)+1;
9146 423 break;
9147
9148 case right:
9149 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9150 91 flip=(wall==up?2:0);
9151 91 break;
9152 }
9153
9154 841 }
9155 211789 }
9156 377174 }
9157 else
9158 117732 wallm_crawl();
9159
9160 494906 return enemy::animate(index);
9161 504762 }
9162
9163 117732 void eWallM::wallm_crawl()
9164 {
9165 117732 bool w=watch;
9166 117732 hxofs=0;
9167
9168
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9169 {
9170 810 return;
9171 }
9172
9173 // if(dying || watch || (!hashero && stunclk))
9174
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9175 {
9176 14546 return;
9177 }
9178
9179 102376 watch=false;
9180 102376 ++clk2;
9181 // Misc1: slightly different movement
9182 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9183
9184 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9186
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9187 {
9188 4491 --clk2;
9189 4491 }
9190
9191
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9192 {
9193 case 1:
9194 case 2:
9195 52852 zc_swap(dir,clk3);
9196 52852 move(step);
9197 52852 zc_swap(dir,clk3);
9198 52852 break;
9199
9200 case 3:
9201 case 4:
9202 case 5:
9203
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9204 {
9205 4491 watch=w;
9206 4491 return;
9207 }
9208
9209 34905 move(step);
9210 34905 break;
9211
9212 case 6:
9213 case 7:
9214 9984 zc_swap(dir,clk3);
9215 9984 dir^=1;
9216 9984 move(step);
9217 9984 dir^=1;
9218 9984 zc_swap(dir,clk3);
9219 9984 break;
9220
9221 default:
9222 144 misc=0;
9223 144 break;
9224 }
9225
9226 97885 watch=w;
9227 117732 }
9228
9229 9 void eWallM::grabhero()
9230 {
9231 9 hashero=true;
9232 9 superman=1;
9233 9 }
9234
9235 507147 void eWallM::draw(BITMAP *dest)
9236 {
9237 507147 dummy_bool[1]=hashero;
9238 507147 update_enemy_frame();
9239
9240
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9241 {
9242 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9243 129181 }
9244
9245 // enemy::draw(dest);
9246 // tile = clk&8 ? 128:129;
9247 507147 }
9248
9249 bool eWallM::isSubmerged() const
9250 {
9251 return ( !misc );
9252 }
9253
9254 1680 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9255 1680 {
9256
1/2
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
1680 ox=x; //original x
9257
1/2
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
1680 oy=y; //original y
9258
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 206 times.
1680 if(get_qr(qr_TRAPPOSFIX))
9259 {
9260
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
✓ Branch 2 taken 206 times.
✗ Branch 3 not taken.
206 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9261 206 }
9262
9263 1680 mainguy=false;
9264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9265 //nets+420;
9266 1680 dummy_int[1]=0;
9267
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1680 if (SIZEflags != 0) init_size_flags();;
9268 1680 }
9269
9270 1054519 bool eTrap::animate(int32_t index)
9271 {
9272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1054519 times.
1054519 if(switch_hooked) return enemy::animate(index);
9273
2/4
✓ Branch 0 taken 1054519 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1054519 times.
1054519 if(fallclk||drownclk) return enemy::animate(index);
9274
2/2
✓ Branch 0 taken 1032785 times.
✓ Branch 1 taken 21734 times.
1054519 if(clk<0)
9275 21734 return enemy::animate(index);
9276
9277
2/2
✓ Branch 0 taken 967448 times.
✓ Branch 1 taken 65337 times.
1032785 if(clk==0)
9278 {
9279 65337 removearmos(x,y);
9280 65337 }
9281
9282
2/2
✓ Branch 0 taken 321964 times.
✓ Branch 1 taken 710821 times.
1032785 if(misc==0) // waiting
9283 {
9284 710821 ox = x;
9285 710821 oy = y;
9286 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9287 710821 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9288
9289
4/4
✓ Branch 0 taken 247420 times.
✓ Branch 1 taken 463401 times.
✓ Branch 2 taken 137375 times.
✓ Branch 3 taken 110045 times.
710821 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9290 {
9291 110045 dir=down;
9292 110045 }
9293
4/4
✓ Branch 0 taken 398123 times.
✓ Branch 1 taken 202653 times.
✓ Branch 2 taken 137375 times.
✓ Branch 3 taken 260748 times.
600776 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9294 {
9295 260748 dir=right;
9296 260748 }
9297
4/4
✓ Branch 0 taken 216363 times.
✓ Branch 1 taken 123665 times.
✓ Branch 2 taken 137375 times.
✓ Branch 3 taken 78988 times.
340028 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9298 {
9299 78988 dir=up;
9300 78988 }
9301 else
9302 {
9303 261040 dir=left;
9304 }
9305
9306 710821 int32_t d2=lined_up(15,true);
9307
9308
4/4
✓ Branch 0 taken 272171 times.
✓ Branch 1 taken 438650 times.
✓ Branch 2 taken 1110486 times.
✓ Branch 3 taken 399665 times.
1107466 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9309
2/2
✓ Branch 0 taken 234727 times.
✓ Branch 1 taken 164938 times.
399665 ((d2>down) && (dmisc1==2)) ||
9310
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 31043 times.
164938 ((d2>right) && (!dmisc1)) ||
9311
2/2
✓ Branch 0 taken 396645 times.
✓ Branch 1 taken 178533 times.
218112 ((d2<l_up) && (dmisc1==4)) ||
9312
3/4
✓ Branch 0 taken 396645 times.
✓ Branch 1 taken 218112 times.
✓ Branch 2 taken 396645 times.
✗ Branch 3 not taken.
178533 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9313
3/4
✓ Branch 0 taken 396645 times.
✓ Branch 1 taken 178533 times.
✓ Branch 2 taken 396645 times.
✗ Branch 3 not taken.
218112 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9314 {
9315 2535148 d2=-1;
9316 2535148 }
9317
9318
4/4
✓ Branch 0 taken 20966 times.
✓ Branch 1 taken 471743 times.
✓ Branch 2 taken 18829 times.
✓ Branch 3 taken 2137 times.
492709 if(d2!=-1 && trapmove(d2))
9319 {
9320 2137 dir=d2;
9321 2137 misc=1;
9322 2137 clk2=(dir==down)?3:0;
9323 2137 }
9324 492709 }
9325
9326
2/2
✓ Branch 0 taken 724331 times.
✓ Branch 1 taken 90342 times.
814673 if(misc==1) // charging
9327 {
9328 90342 clk2=(clk2+1)&3;
9329 90342 step=(clk2==3)?1:2;
9330
9331
4/4
✓ Branch 0 taken 89516 times.
✓ Branch 1 taken 826 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 88411 times.
90342 if(!trapmove(dir) || clip())
9332 {
9333 1931 misc=2;
9334
9335
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 if(dir<l_up)
9336 {
9337 1931 dir=dir^1;
9338 1931 }
9339 else
9340 {
9341 dir=dir^3;
9342 }
9343 1931 }
9344 else
9345 {
9346 88411 sprite::move(step);
9347 }
9348 90342 }
9349
9350
2/2
✓ Branch 0 taken 578983 times.
✓ Branch 1 taken 235690 times.
814673 if(misc==2) // retreating
9351 {
9352 235690 step=(++clk2&1)?1:0;
9353
9354
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39305 times.
✓ Branch 2 taken 81283 times.
✓ Branch 3 taken 29536 times.
✓ Branch 4 taken 85566 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
235690 switch(dir)
9355 {
9356 case up:
9357
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 39030 times.
39305 if(int32_t(y)<=oy) goto trap_rest;
9358 39030 else sprite::move(step);
9359
9360 39030 break;
9361
9362 case left:
9363
2/2
✓ Branch 0 taken 394 times.
✓ Branch 1 taken 80889 times.
81283 if(int32_t(x)<=ox) goto trap_rest;
9364 80889 else sprite::move(step);
9365
9366 80889 break;
9367
9368 case down:
9369
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 29310 times.
29536 if(int32_t(y)>=oy) goto trap_rest;
9370 29310 else sprite::move(step);
9371
9372 29310 break;
9373
9374 case right:
9375
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 85127 times.
85566 if(int32_t(x)>=ox) goto trap_rest;
9376 85127 else sprite::move(step);
9377
9378 85127 break;
9379
9380 case l_up:
9381 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9382 else sprite::move(step);
9383
9384 break;
9385
9386 case r_up:
9387 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9388 else sprite::move(step);
9389
9390 break;
9391
9392 case l_down:
9393 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9394 else sprite::move(step);
9395
9396 break;
9397
9398 case r_down:
9399 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9400 else sprite::move(step);
9401
9402 break;
9403 trap_rest:
9404 {
9405 1334 x=ox;
9406 1334 y=oy;
9407 1334 misc=0;
9408 }
9409 1334 }
9410 235690 }
9411
9412 814673 return enemy::animate(index);
9413 836407 }
9414
9415 111308 bool eTrap::trapmove(int32_t ndir)
9416 {
9417
2/2
✓ Branch 0 taken 81544 times.
✓ Branch 1 taken 29764 times.
111308 if(get_qr(qr_MEANTRAPS))
9418 {
9419 81544 mapscr* scr = get_scr(screen_spawned);
9420
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 80204 times.
81544 if(scr->flags2&fFLOATTRAPS)
9421 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9422
9423 80204 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9424 }
9425
9426
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9427 4730 return false;
9428
9429
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9430 return false;
9431
9432
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9433 return false;
9434
9435
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9436 return false;
9437
9438
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9439 4722 return false;
9440
9441
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9442 713 return false;
9443
9444
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9445 return false;
9446
9447
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9448 return false;
9449
9450
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9451 return false;
9452
9453
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9454 return false;
9455
9456 19599 return true;
9457 111308 }
9458
9459 89516 bool eTrap::clip()
9460 {
9461
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 46494 times.
89516 if(get_qr(qr_MEANPLACEDTRAPS))
9462 {
9463
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5954 times.
✓ Branch 2 taken 8764 times.
✓ Branch 3 taken 16437 times.
✓ Branch 4 taken 15339 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
46494 switch(dir)
9464 {
9465 case up:
9466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5954 times.
5954 if(y<=0) return true;
9467
9468 5954 break;
9469
9470 case down:
9471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8764 times.
8764 if(y>=world_h-16) return true;
9472
9473 8764 break;
9474
9475 case left:
9476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16437 times.
16437 if(x<=0) return true;
9477
9478 16437 break;
9479
9480 case right:
9481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15339 times.
15339 if(x>=world_w-16) return true;
9482
9483 15339 break;
9484
9485 case l_up:
9486 if(y<=0||x<=0) return true;
9487
9488 break;
9489
9490 case l_down:
9491 if(y>=world_h-16||x<=0) return true;
9492
9493 break;
9494
9495 case r_up:
9496 if(y<=0||x>=world_w-16) return true;
9497
9498 break;
9499
9500 case r_down:
9501 if(y>=world_h-16||x>=world_w-16) return true;
9502
9503 break;
9504 }
9505
9506 46494 return false;
9507 }
9508 else
9509 {
9510
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9511 {
9512 case up:
9513
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9514
9515 4695 break;
9516
9517 case down:
9518
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9519
9520 5253 break;
9521
9522 case left:
9523
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9524
9525 16376 break;
9526
9527 case right:
9528
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9529
9530 15593 break;
9531
9532 case l_up:
9533 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9534
9535 break;
9536
9537 case l_down:
9538 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9539
9540 break;
9541
9542 case r_up:
9543 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9544
9545 break;
9546
9547 case r_down:
9548 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9549
9550 break;
9551 }
9552
9553 41917 return false;
9554 }
9555 89516 }
9556
9557 1073433 void eTrap::draw(BITMAP *dest)
9558 {
9559 1073433 update_enemy_frame();
9560 1073433 enemy::draw(dest);
9561 1073433 }
9562
9563 5755 int32_t eTrap::takehit(weapon*,weapon*)
9564 {
9565 5755 return 0;
9566 }
9567
9568 893 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9569 893 {
9570 893 lasthit=-1;
9571 893 lasthitclk=0;
9572 893 mainguy=false;
9573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9574
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 step=2;
9575
3/6
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9576 {
9577
2/4
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 436 times.
✗ Branch 3 not taken.
436 dir=(x<=112)?right:left;
9578 436 }
9579 else
9580 {
9581
2/4
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 457 times.
✗ Branch 3 not taken.
457 dir=(y<=72)?down:up;
9582 }
9583
9584
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 133 times.
893 if(get_qr(qr_TRAPPOSFIX))
9585 {
9586
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9587 133 }
9588
9589 //nets+((id==eTRAP_LR)?540:520);
9590 893 dummy_int[1]=0;
9591
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if (SIZEflags != 0) init_size_flags();;
9592 893 }
9593
9594 370041 bool eTrap2::animate(int32_t index)
9595 {
9596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 370041 times.
370041 if(switch_hooked) return enemy::animate(index);
9597
2/4
✓ Branch 0 taken 370041 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 370041 times.
370041 if(fallclk||drownclk) return enemy::animate(index);
9598
2/2
✓ Branch 0 taken 358893 times.
✓ Branch 1 taken 11148 times.
370041 if(clk<0)
9599 11148 return enemy::animate(index);
9600
9601
2/2
✓ Branch 0 taken 22873 times.
✓ Branch 1 taken 336020 times.
358893 if(clk==0)
9602 {
9603 22873 removearmos(x,y);
9604 22873 }
9605
9606
2/2
✓ Branch 0 taken 234567 times.
✓ Branch 1 taken 124326 times.
358893 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9607 {
9608
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9609 {
9610 11074 --lasthitclk;
9611 11074 }
9612 else
9613 {
9614 113252 lasthit=-1;
9615 }
9616
9617 124326 bool hitenemy=false;
9618
9619
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9620 {
9621
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9622 {
9623
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9624 {
9625 3669 lasthit=j;
9626 3669 lasthitclk=10;
9627 3669 hitenemy=true;
9628 3669 guys.spr(j)->lasthit=index;
9629 3669 guys.spr(j)->lasthitclk=10;
9630 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9631 3669 }
9632 730351 }
9633 864860 }
9634
9635
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9636 {
9637
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9638 {
9639 3155 lasthit=-1;
9640 3155 lasthitclk=0;
9641 3155 }
9642
9643
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9644 362 sfx(WAV_ZN1TAP,pan(x));
9645
9646 5986 dir=dir^1;
9647 5986 }
9648
9649 124326 sprite::move(step);
9650 124326 }
9651 else
9652 {
9653
3/4
✓ Branch 0 taken 226871 times.
✓ Branch 1 taken 7696 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 226871 times.
234567 if(!trapmove(dir) || clip())
9654 {
9655
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 2298 times.
7696 if(get_qr(qr_MORESOUNDS))
9656 2298 sfx(WAV_ZN1TAP,pan(x));
9657
9658 7696 dir=dir^1;
9659 7696 }
9660
9661 234567 sprite::move(step);
9662 }
9663
9664 358893 return enemy::animate(index);
9665 370041 }
9666
9667 364879 bool eTrap2::trapmove(int32_t ndir)
9668 {
9669 364879 mapscr* scr = get_scr(screen_spawned);
9670
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 363001 times.
364879 if(scr->flags2&fFLOATTRAPS)
9671 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9672
9673 363001 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9674 364879 }
9675
9676 350873 bool eTrap2::clip()
9677 {
9678
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 94187 times.
✓ Branch 2 taken 94862 times.
✓ Branch 3 taken 80685 times.
✓ Branch 4 taken 81139 times.
350873 switch(dir)
9679 {
9680 case up:
9681
1/2
✓ Branch 0 taken 94187 times.
✗ Branch 1 not taken.
94187 if(y<=0) return true;
9682
9683 94187 break;
9684
9685 case down:
9686
1/2
✓ Branch 0 taken 94862 times.
✗ Branch 1 not taken.
94862 if(y>=world_h-16) return true;
9687
9688 94862 break;
9689
9690 case left:
9691
1/2
✓ Branch 0 taken 80685 times.
✗ Branch 1 not taken.
80685 if(x<=0) return true;
9692
9693 80685 break;
9694
9695 case right:
9696
1/2
✓ Branch 0 taken 81139 times.
✗ Branch 1 not taken.
81139 if(x>=world_w-16) return true;
9697
9698 81139 break;
9699 }
9700
9701 350873 return false;
9702 350873 }
9703
9704 375587 void eTrap2::draw(BITMAP *dest)
9705 {
9706 375587 update_enemy_frame();
9707 375587 enemy::draw(dest);
9708 375587 }
9709
9710 3281 int32_t eTrap2::takehit(weapon*,weapon*)
9711 {
9712 3281 return 0;
9713 }
9714
9715 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9716 354 {
9717 //do not show "enemy appering" anim -DD
9718 354 clk=0;
9719 354 mainguy=false;
9720 354 clk2=-14;
9721 //Enemy Editor Size Tab
9722
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9723 //nets+1640;
9724 354 }
9725
9726 354 void eRock::init_size_flags()
9727 {
9728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9729 354 else hxofs = -2;
9730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9731 354 else hyofs = -2;
9732
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9733 354 else hit_width = 20;
9734
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9735 354 else hit_height = 20;
9736
9737
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9738
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9739
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9740
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9741
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9742 {
9743 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9744 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9745 }
9746
9747
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9748 354 }
9749
9750 121997 bool eRock::animate(int32_t index)
9751 {
9752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9753
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9755 return Dead(index);
9756
9757
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9758 {
9759 8376 removearmos(x,y);
9760 8376 }
9761
9762
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9763 {
9764 697 x=zc_oldrand()&0xF0;
9765 697 y=0;
9766 697 clk3=0;
9767 697 clk2=zc_oldrand()&15;
9768 697 }
9769
9770
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9771 {
9772
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9773 {
9774 3430 dir=zc_oldrand()&1;
9775
9776
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9777
9778
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9779 3430 }
9780
9781
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9782 {
9783 95993 x += dir ? 1 : -1; //right, left
9784 95993 dummy_int[1]=dir;
9785
9786
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9787 {
9788 6852 y-=2; //up
9789 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9790 6852 }
9791
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9792 {
9793 10208 y--; //up
9794 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9795 10208 }
9796
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9797 {
9798 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9799 10135 }
9800
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9801 {
9802 10058 y++; //down
9803 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9804 10058 }
9805 else
9806 {
9807 58740 y+=2; //down
9808 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9809 }
9810
9811 95993 ++clk3;
9812 95993 }
9813
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9814 2761 clk3=0; // next bounce
9815 else
9816 423 clk2 = -(zc_oldrand()&63); // back to top
9817 99177 }
9818
9819 121997 return enemy::animate(index);
9820 121997 }
9821
9822 51441 bool eRock::can_drawshadow() const
9823 {
9824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51441 times.
51441 if(shadow_overpit())
9825 return false;
9826
9827 51441 return clk2>=0;
9828 51441 }
9829 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9830 {
9831
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(!can_drawshadow())
9832 7191 return;
9833 44250 int32_t tempy=yofs;
9834 44250 flip = 0;
9835 44250 int32_t fdiv = frate/4;
9836
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9837
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9838 44250 efrate:((clk>=(frate>>1))?1:0);
9839 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9840
9841 44250 yofs+=8;
9842
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9843 44250 sprite::drawshadow(dest, translucent);
9844 44250 yofs=tempy;
9845 51441 }
9846
9847 122078 void eRock::draw(BITMAP *dest)
9848 {
9849
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9850 {
9851 105043 int32_t tempdir=dir;
9852 105043 dir=dummy_int[2];
9853 105043 update_enemy_frame();
9854 105043 enemy::draw(dest);
9855 105043 dir=tempdir;
9856 105043 }
9857 122078 }
9858
9859 1014 int32_t eRock::takehit(weapon*,weapon*)
9860 {
9861 1014 return 0;
9862 }
9863
9864 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9865 30 {
9866 30 clk=0;
9867 30 mainguy=false;
9868 30 clk2=-14;
9869
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9870 //nets+1680;
9871 30 }
9872
9873 4440 bool eBoulder::animate(int32_t index)
9874 {
9875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9876
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9878 return Dead(index);
9879
9880
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9881 {
9882 290 removearmos(x,y);
9883 290 }
9884
9885 zfix *vert;
9886
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9887
9888
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9889 {
9890 32 x=zc_oldrand()&0xF0;
9891 32 y=-32;
9892 32 clk3=0;
9893 32 clk2=zc_oldrand()&15;
9894 32 }
9895
9896
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
9897 {
9898
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
9899 {
9900 131 dir=zc_oldrand()&1;
9901
9902
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
9903
9904
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
9905 131 }
9906
9907
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
9908 {
9909 3487 x += dir ? 1 : -1; //right, left
9910 3487 dummy_int[1]=dir;
9911
9912
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
9913 {
9914 261 y-=2; //up
9915 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9916 261 }
9917
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
9918 {
9919 382 y--; //up
9920 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9921 382 }
9922
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
9923 {
9924 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
9925 376 }
9926
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
9927 {
9928 367 y++; //down
9929 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9930 367 }
9931 else
9932 {
9933 2101 y+=2; //down
9934 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9935 }
9936
9937 3487 ++clk3;
9938 3487 }
9939
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
9940 101 clk3=0; // next bounce
9941 else
9942 10 clk2 = -(zc_oldrand()&63); // back to top
9943 3598 }
9944
9945 4440 return enemy::animate(index);
9946 4440 }
9947
9948 4440 bool eBoulder::can_drawshadow() const
9949 {
9950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(shadow_overpit())
9951 return false;
9952
9953 4440 return clk2>=0;
9954 4440 }
9955 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
9956 {
9957
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(!can_drawshadow())
9958 572 return;
9959 3868 int32_t tempy=yofs;
9960 3868 flip = 0;
9961 3868 int32_t f2=((clk<<2)/frate)<<1;
9962 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9963
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9964
9965 3868 yofs+=8;
9966 3868 xofs-=8;
9967 3868 sprite::drawshadow(dest, translucent);
9968 3868 xofs+=16;
9969 3868 ++shadowtile;
9970 3868 sprite::drawshadow(dest, translucent);
9971 3868 yofs+=16;
9972 3868 shadowtile+=20;
9973 3868 sprite::drawshadow(dest, translucent);
9974 3868 xofs-=16;
9975 3868 --shadowtile;
9976 3868 sprite::drawshadow(dest, translucent);
9977 3868 xofs+=8;
9978 3868 yofs=tempy;
9979 4440 }
9980
9981 4440 void eBoulder::draw(BITMAP *dest)
9982 {
9983
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
9984 {
9985 3868 int32_t tempdir=dir;
9986 3868 dir=dummy_int[2];
9987 3868 update_enemy_frame();
9988 3868 dir=tempdir;
9989 3868 xofs-=8;
9990 3868 yofs-=8;
9991 3868 drawblock(dest,15);
9992 3868 xofs+=8;
9993 3868 yofs+=8;
9994 // enemy::draw(dest);
9995 3868 }
9996 4440 }
9997
9998 30 void eBoulder::init_size_flags()
9999 {
10000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10001 30 else hxofs = -10;
10002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10003 30 else hyofs = -10;
10004
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10005 30 else hit_width = 36;
10006
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10007 30 else hit_height = 36;
10008
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10009 30 else hzsz = 16; //can't be jumped
10010
10011
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10012
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10014
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10015
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10016 {
10017 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10018 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10019 }
10020
10021
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10022 30 }
10023
10024 int32_t eBoulder::takehit(weapon*,weapon*)
10025 {
10026 return 0;
10027 }
10028
10029 4433 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10030
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 3898 times.
4433 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10031 4433 {
10032 /* fixing
10033 hp=1;
10034 */
10035 4433 mainguy=false;
10036
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4426 times.
4433 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10037 4433 hclk=clk; // the "no fire" range
10038 4433 clk=0;
10039 4433 clk3=96;
10040 4433 timer=0;
10041
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4415 times.
4433 if(o_tile==0)
10042 {
10043 4415 superman=1;
10044 4415 hxofs=1000;
10045 4415 }
10046
1/4
✓ Branch 0 taken 4433 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4433 if (SIZEflags != 0) init_size_flags();;
10047 4433 }
10048
10049 2505003 bool eProjectile::animate(int32_t index)
10050 {
10051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2505003 times.
2505003 if(switch_hooked) return enemy::animate(index);
10052
2/4
✓ Branch 0 taken 2505003 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2505003 times.
2505003 if(fallclk||drownclk) return enemy::animate(index);
10053
2/2
✓ Branch 0 taken 2492673 times.
✓ Branch 1 taken 12330 times.
2505003 if(clk==0)
10054 {
10055 12330 removearmos(x,y);
10056 12330 }
10057
10058 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10059 2505003 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10060
10061
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669395 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2505003 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10062 {
10063 403631 dir=down;
10064 403631 }
10065
4/4
✓ Branch 0 taken 1349154 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 917177 times.
2101372 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10066 {
10067 917177 dir=right;
10068 917177 }
10069
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10070 {
10071 358900 dir=up;
10072 358900 }
10073 else
10074 {
10075 825295 dir=left;
10076 }
10077
10078
3/4
✓ Branch 0 taken 2505003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306384 times.
✓ Branch 3 taken 1198619 times.
2505003 if(!stunclk && ++clk3>80)
10079 {
10080
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197573 times.
1198619 if(dmisc1==9) // Breath type
10081 {
10082
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10083 {
10084 563 unsigned r=zc_oldrand();
10085
10086
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10087 {
10088 6 timer=zc_oldrand()%50+50;
10089 6 }
10090 563 }
10091
10092
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10093 {
10094
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10095 {
10096 119 FireBreath(false);
10097 119 }
10098
10099
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10100 {
10101 6 clk3=0;
10102 6 }
10103 489 }
10104 1046 }
10105
10106 else // Not breath type
10107 {
10108 1197573 unsigned r=zc_oldrand();
10109
10110
4/4
✓ Branch 0 taken 18811 times.
✓ Branch 1 taken 1178762 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17545 times.
1197573 if(!(r&63) && !HeroInRange(minRange))
10111 {
10112 17545 FireWeapon();
10113
10114
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2505 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17797 if(get_qr(qr_BROKENSTATUES)==0 &&
10115
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10116 {
10117
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10118 {
10119 909 x-=4;
10120 909 FireWeapon();
10121 909 x+=4;
10122 909 }
10123 14854 }
10124
10125 17545 clk3=0;
10126 17545 }
10127 }
10128 1198619 }
10129
10130 2505003 return enemy::animate(index);
10131 2505003 }
10132
10133 2520592 void eProjectile::draw(BITMAP *dest)
10134 {
10135 2520592 update_enemy_frame();
10136 2520592 enemy::draw(dest);
10137 2520592 }
10138
10139 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10140 533 {
10141 533 hxofs=1000;
10142 533 }
10143
10144 249811 void eTrigger::draw(BITMAP *dest)
10145 {
10146 249811 update_enemy_frame();
10147 249811 enemy::draw(dest);
10148 249811 }
10149
10150 void eTrigger::death_sfx()
10151 {
10152 //silent death
10153 }
10154
10155 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10156 5 {
10157 5 o_tile+=wpnsbuf[iwNPCs].tile;
10158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10159 5 SIZEflags = d->SIZEflags;
10160
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10161 5 }
10162
10163 75 bool eNPC::animate(int32_t index)
10164 {
10165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10166
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10167 70 return Dead(index);
10168
10169
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10170 {
10171 removearmos(x,y);
10172 }
10173
10174
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10175 {
10176 case 0:
10177 {
10178 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10179 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10180
10181
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10182 {
10183 dir=down;
10184 }
10185
10186
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10187 {
10188 5 dir=right;
10189 5 }
10190 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10191 {
10192 dir=up;
10193 }
10194 else
10195 {
10196 dir=left;
10197 }
10198 }
10199 5 break;
10200
10201 case 1:
10202 halting_walk(rate, homing, 0, hrate, 48);
10203
10204 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10205 {
10206 newdir(rate, homing, 0);
10207 clk2=48;
10208 ++misc;
10209 }
10210
10211 if(clk2==0)
10212 misc=0;
10213
10214 break;
10215 }
10216
10217 5 return enemy::animate(index);
10218 75 }
10219
10220 75 void eNPC::draw(BITMAP *dest)
10221 {
10222 75 update_enemy_frame();
10223 75 enemy::draw(dest);
10224 75 }
10225
10226 int32_t eNPC::takehit(weapon*,weapon*)
10227 {
10228 return 0;
10229 }
10230
10231 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10232 94 {
10233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10234 {
10235 94 o_tile=clk;
10236 94 cs=id>>12;
10237 94 }
10238
10239 94 id=id&0xFFF;
10240 94 clk=0;
10241
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10242 94 mainguy=false;
10243 94 SIZEflags = d->SIZEflags;
10244
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10245 94 }
10246
10247 81 void eSpinTile::facehero()
10248 {
10249
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10250 {
10251
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10252 1 dir = up;
10253 else
10254 dir = down;
10255 1 }
10256 else
10257 {
10258 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10259 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10260
10261
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10262 {
10263 12 dir=l_down;
10264 12 }
10265
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10266 {
10267 1 dir=down;
10268 1 }
10269
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10270 {
10271 12 dir=r_down;
10272 12 }
10273
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10274 {
10275 6 dir=right;
10276 6 }
10277
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10278 {
10279 17 dir=r_up;
10280 17 }
10281
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10282 {
10283 8 dir=up;
10284 8 }
10285
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10286 {
10287 6 dir=l_up;
10288 6 }
10289 else
10290 {
10291 18 dir=left;
10292 }
10293 }
10294 81 }
10295
10296
10297 15539 bool eSpinTile::animate(int32_t index)
10298 {
10299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10300
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10301
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10302 {
10303 1152 return Dead(index);
10304 }
10305
10306
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10307 {
10308 1241 removearmos(x,y);
10309 1241 }
10310
10311 14387 ++misc;
10312
10313
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10314 {
10315 81 facehero();
10316 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10317 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10318 81 angular=true;
10319 81 angle=ddir;
10320 81 step=zslongToFix(dstep*100);
10321 81 }
10322
10323
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10324 52 kickbucket();
10325
10326 14387 sprite::move(step);
10327 14387 return enemy::animate(index);
10328 15539 }
10329
10330 15457 void eSpinTile::draw(BITMAP *dest)
10331 {
10332 15457 update_enemy_frame();
10333 15457 y-=(misc>>4);
10334 15457 yofs+=2;
10335 15457 enemy::draw(dest);
10336 15457 yofs-=2;
10337 15457 y+=(misc>>4);
10338 15457 }
10339
10340 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10341 {
10342 15457 flip = 0;
10343
1/2
✓ Branch 0 taken 15457 times.
✗ Branch 1 not taken.
15457 if(!can_drawshadow())
10344 15457 return;
10345 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10346 yofs+=4;
10347 enemy::drawshadow(dest, translucent);
10348 yofs-=4;
10349 15457 }
10350
10351 2874 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10352 2874 {
10353 //these are here to bypass compiler warnings about unused arguments
10354 2874 Clk=Clk;
10355 2874 mainguy=false;
10356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2874 times.
2874 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10357
1/4
✓ Branch 0 taken 2874 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2874 if (SIZEflags != 0) init_size_flags();;
10358 2874 }
10359
10360 643945 void eZora::facehero()
10361 {
10362
2/2
✓ Branch 0 taken 10802 times.
✓ Branch 1 taken 633143 times.
643945 if(Hero.x-x==0)
10363 {
10364 10802 dir=(Hero.y+8<y)?up:down;
10365 10802 }
10366 else
10367 {
10368 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10369 633143 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10370
10371
4/4
✓ Branch 0 taken 128467 times.
✓ Branch 1 taken 504676 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 79916 times.
633143 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10372 {
10373 79916 dir=l_down;
10374 79916 }
10375
4/4
✓ Branch 0 taken 94203 times.
✓ Branch 1 taken 459024 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 45652 times.
553227 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10376 {
10377 45652 dir=down;
10378 45652 }
10379
4/4
✓ Branch 0 taken 123472 times.
✓ Branch 1 taken 384103 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 74921 times.
507575 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10380 {
10381 74921 dir=r_down;
10382 74921 }
10383
4/4
✓ Branch 0 taken 166271 times.
✓ Branch 1 taken 266383 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 117720 times.
432654 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10384 {
10385 117720 dir=right;
10386 117720 }
10387
4/4
✓ Branch 0 taken 130916 times.
✓ Branch 1 taken 184018 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 82365 times.
314934 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10388 {
10389 82365 dir=r_up;
10390 82365 }
10391
4/4
✓ Branch 0 taken 91723 times.
✓ Branch 1 taken 140846 times.
✓ Branch 2 taken 48551 times.
✓ Branch 3 taken 43172 times.
232569 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10392 {
10393 43172 dir=up;
10394 43172 }
10395
4/4
✓ Branch 0 taken 126673 times.
✓ Branch 1 taken 62724 times.
✓ Branch 2 taken 78122 times.
✓ Branch 3 taken 48551 times.
189397 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10396 {
10397 78122 dir=l_up;
10398 78122 }
10399 else
10400 {
10401 111275 dir=left;
10402 }
10403 }
10404 643945 }
10405
10406 872768 bool eZora::animate(int32_t index)
10407 {
10408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 872768 times.
872768 if(switch_hooked) return enemy::animate(index);
10409
2/2
✓ Branch 0 taken 2954 times.
✓ Branch 1 taken 869814 times.
872768 if(dying)
10410 2954 return Dead(index);
10411
10412
2/2
✓ Branch 0 taken 863948 times.
✓ Branch 1 taken 5866 times.
869814 if(clk==0)
10413 {
10414 5866 removearmos(x,y);
10415 5866 }
10416
10417
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 869779 times.
869814 if(watch)
10418 {
10419 35 clock_zoras.push_back({screen_spawned, id});
10420 35 return true;
10421 }
10422
10423
2/2
✓ Branch 0 taken 225834 times.
✓ Branch 1 taken 643945 times.
869779 if(get_qr(qr_NEWENEMYTILES))
10424 {
10425 643945 facehero();
10426 643945 }
10427
10428
6/6
✓ Branch 0 taken 5341 times.
✓ Branch 1 taken 5092 times.
✓ Branch 2 taken 4266 times.
✓ Branch 3 taken 845474 times.
✓ Branch 4 taken 6586 times.
✓ Branch 5 taken 3020 times.
869779 switch(clk)
10429 {
10430 case 0: // reposition him
10431 {
10432 6586 int32_t t=0;
10433 6586 int32_t pos2=zc_oldrand()%160 + 16;
10434 6586 bool placed=false;
10435
10436
4/4
✓ Branch 0 taken 6514 times.
✓ Branch 1 taken 40421 times.
✓ Branch 2 taken 28041 times.
✓ Branch 3 taken 5866 times.
46935 while(!placed && t<160)
10437 {
10438 28041 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10439 95711 auto [sx, sy] = COMBOXY_REGION(rpos);
10440 28041 mapscr* s = get_scr(screen_spawned);
10441
10442 84123 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10443
6/6
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 21321 times.
✓ Branch 2 taken 6709 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 403 times.
✓ Branch 5 taken 5794 times.
34238 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10444
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6677 times.
6709 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10445
3/4
✓ Branch 0 taken 6677 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6197 times.
✓ Branch 3 taken 6154 times.
6720 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10446 {
10447 5794 x=sx;
10448 5794 y=sy;
10449
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5454 times.
5794 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10450 5794 hxofs=1000; // avoid hit detection
10451 5794 stunclk=0;
10452 5794 placed=true;
10453 5794 }
10454
10455 40349 pos2+=19;
10456
10457
2/2
✓ Branch 0 taken 35573 times.
✓ Branch 1 taken 4776 times.
40349 if(pos2>=176)
10458 4776 pos2-=160;
10459
10460 40349 ++t;
10461 }
10462
10463
3/4
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5794 times.
5866 if(!placed || whistleclk>=88) // can't place him, he's gone
10464 72 return true;
10465
10466 }
10467 5794 break;
10468
10469 case 35:
10470
2/2
✓ Branch 0 taken 3980 times.
✓ Branch 1 taken 1361 times.
5341 if(!get_qr(qr_NEWENEMYTILES))
10471 {
10472 1361 dir=(Hero.y+8<y)?up:down;
10473 1361 }
10474
10475 5341 hxofs=0;
10476 5341 break;
10477
10478 case 35+19:
10479 5092 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10480 5092 sfx(wpnsfx(wpn),pan(x));
10481 5092 break;
10482
10483 case 35+66:
10484 4266 hxofs=1000;
10485 4266 break;
10486
10487 case 198:
10488 3020 clk=-1;
10489 3020 break;
10490 }
10491
10492 868987 return enemy::animate(index);
10493 872048 }
10494
10495 884024 void eZora::draw(BITMAP *dest)
10496 {
10497
2/2
✓ Branch 0 taken 20355 times.
✓ Branch 1 taken 863669 times.
884024 if (isSubmerged())
10498 20355 return;
10499
10500 863669 update_enemy_frame();
10501 863669 enemy::draw(dest);
10502 884024 }
10503
10504 884256 bool eZora::isSubmerged() const
10505 {
10506 884256 return clk < 3;
10507 }
10508
10509
3/6
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52553 times.
✗ Branch 5 not taken.
105106 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10510 52553 {
10511 52553 multishot= timer = fired = dashing = 0;
10512 52553 hashero = false;
10513 52553 dummy_bool[0]=false;
10514
4/8
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52553 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52553 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 52553 times.
✗ Branch 7 not taken.
52553 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10515
5/6
✓ Branch 0 taken 1004 times.
✓ Branch 1 taken 51549 times.
✓ Branch 2 taken 1004 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 520 times.
✓ Branch 5 taken 484 times.
52553 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10516 {
10517
2/4
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 520 times.
✗ Branch 3 not taken.
520 step=zslongToFix(dmisc10*100);
10518
10519
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 502 times.
520 if(anim==aARMOS4) o_tile+=20;
10520 520 }
10521
10522
3/4
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1004 times.
✓ Branch 3 taken 51549 times.
52553 if(flags & guy_fade_flicker)
10523 {
10524 1004 clk=0;
10525 1004 superman = 1;
10526 1004 fading=fade_flicker;
10527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1004 times.
1004 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10528 1004 dir=down;
10529
10530
4/6
✓ Branch 0 taken 1004 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1004 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 443 times.
✓ Branch 5 taken 561 times.
1004 if(!canmove(down,(zfix)8,spw_none,false))
10531
3/6
✓ Branch 0 taken 443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 443 times.
✗ Branch 5 not taken.
443 clk3=int32_t(13.0/step);
10532 1004 }
10533
3/4
✓ Branch 0 taken 51549 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51416 times.
✓ Branch 3 taken 133 times.
51549 else if(flags & guy_fade_instant)
10534 {
10535 133 clk=0;
10536 133 }
10537
10538
1/2
✓ Branch 0 taken 52553 times.
✗ Branch 1 not taken.
52553 shadowdistance = 0;
10539 52553 clk4 = clk5 = 0;
10540 //nets+2380;
10541
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 52551 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
52553 if (SIZEflags != 0) init_size_flags();;
10542 52553 }
10543
10544 16383593 bool eStalfos::animate(int32_t index)
10545 {
10546
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 16383337 times.
16383593 if(switch_hooked) return enemy::animate(index);
10547
4/4
✓ Branch 0 taken 16382414 times.
✓ Branch 1 taken 923 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 16381070 times.
16383337 if(fallclk||drownclk)
10548 {
10549 2267 return enemy::animate(index);
10550 }
10551
2/2
✓ Branch 0 taken 369776 times.
✓ Branch 1 taken 16011294 times.
16381070 if(dying)
10552 {
10553
2/2
✓ Branch 0 taken 369725 times.
✓ Branch 1 taken 51 times.
369776 if(hashero)
10554 {
10555 51 Hero.setEaten(0);
10556 51 hashero=false;
10557 51 }
10558
10559
10/14
✓ Branch 0 taken 38171 times.
✓ Branch 1 taken 331605 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 34486 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
369776 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10560 {
10561 187 hp=-1000;
10562
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10563 187 Ewpns.add(ew);
10564 187 ew->fakez = fakez;
10565
10566
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10567 {
10568 187 ew->step=0;
10569 187 ew->id=wpn;
10570 187 ew->misc=50;
10571 187 ew->clk=48;
10572 187 }
10573
10574 187 fired=true;
10575 187 }
10576
6/6
✓ Branch 0 taken 163945 times.
✓ Branch 1 taken 205644 times.
✓ Branch 2 taken 137553 times.
✓ Branch 3 taken 26392 times.
✓ Branch 4 taken 137535 times.
✓ Branch 5 taken 18 times.
369589 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10577 {
10578
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10579 {
10580 1 int32_t wpn2 = wpn+dmisc3;
10581
10582
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10583 {
10584 wpn2=wpn;
10585 }
10586
10587 1 dummy_bool[0]=true;
10588 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10589 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10590 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10591 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10592 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10593 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10594 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10595 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10596 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10597 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10598 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10599 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10600 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10601 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10602 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10603 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10604 1 sfx(wpnsfx(wpn2),pan(x));
10605 1 }
10606 18 }
10607
10608 369776 KillWeapon();
10609 369776 return Dead(index);
10610 }
10611 //vire split
10612 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10613 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10614
13/14
✓ Branch 0 taken 22021 times.
✓ Branch 1 taken 15989273 times.
✓ Branch 2 taken 22021 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 390 times.
✓ Branch 5 taken 21631 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14818208 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
16011294 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10615 {
10616 1716 stop_bgsfx(index);
10617 1716 int32_t kids = guys.Count();
10618 1716 int32_t id2=dmisc3;
10619
2/2
✓ Branch 0 taken 3385 times.
✓ Branch 1 taken 1716 times.
5101 for(int32_t i=0; i < dmisc4; i++)
10620 {
10621
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2113 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3385 times.
3385 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].type==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10622 3385 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10623 3385 }
10624
10625
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1716 if (itemguy && guys.Count()) // Hand down the carried item
10626 {
10627 1 int guycarryingitem = guys.Count()-1;
10628 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10629 1 itemguy = false;
10630 1 }
10631
10632
2/2
✓ Branch 0 taken 1699 times.
✓ Branch 1 taken 17 times.
1716 if(hashero)
10633 {
10634 17 Hero.setEaten(0);
10635 17 hashero=false;
10636 17 }
10637
10638
4/4
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 362 times.
1716 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10639 362 sfx(deadsfx,pan(x));
10640
10641 1716 return true;
10642 }
10643
10644
2/2
✓ Branch 0 taken 71283 times.
✓ Branch 1 taken 15938295 times.
16009578 if(fading)
10645 {
10646
2/2
✓ Branch 0 taken 1230 times.
✓ Branch 1 taken 70053 times.
71283 if(++clk4 > 60)
10647 {
10648 1230 clk4=0;
10649 1230 superman=0;
10650 1230 fading=0;
10651
10652
4/6
✓ Branch 0 taken 969 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 969 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 969 times.
1230 if(flags&guy_armos && z==0 && fakez == 0)
10653 {
10654 //if a custom size (not 16px by 16px)
10655
10656 //if a custom size (not 16px by 16px)
10657
3/4
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 791 times.
✓ Branch 2 taken 178 times.
✗ Branch 3 not taken.
969 if (activated_handle && !activated_handle->is_rpos())
10658 removearmos(x,y);
10659 else
10660 {
10661
4/8
✓ Branch 0 taken 969 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 969 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 969 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 969 times.
969 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10662 {
10663 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10664 for(int32_t dx = 0; dx < tysz; dx ++)
10665 {
10666 for(int32_t dy = 0; dy < tysz; dy++)
10667 {
10668 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10669 did_armos = false;
10670 }
10671 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10672 did_armos = false;
10673 }
10674 for(int32_t dy = 0; dy < tysz; dy ++)
10675 {
10676 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10677 did_armos = false;
10678 }
10679 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10680 }
10681 969 else removearmos(x,y);
10682 }
10683
10684 969 }
10685
10686 1230 clk2=0;
10687
10688 1230 newdir();
10689 1230 }
10690 70053 else return enemy::animate(index);
10691 1230 }
10692
6/8
✓ Branch 0 taken 148631 times.
✓ Branch 1 taken 15789664 times.
✓ Branch 2 taken 148631 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148631 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139061 times.
✓ Branch 7 taken 9570 times.
15938295 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10693 9570 removearmos(x,y);
10694
10695
10696
2/2
✓ Branch 0 taken 7873 times.
✓ Branch 1 taken 15931652 times.
15939525 if(hashero)
10697 {
10698 7873 Hero.setX(x);
10699 7873 Hero.setY(y);
10700 7873 ++clk2;
10701
10702
4/4
✓ Branch 0 taken 6360 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6784 times.
✓ Branch 3 taken 1089 times.
7873 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10703 {
10704
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1058 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
1089 switch(dmisc7)
10705 {
10706 case e7tEATITEMS:
10707 {
10708
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10709 {
10710
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10711 22 game->set_item(i, false);
10712 5632 }
10713
10714 22 break;
10715 }
10716
10717 case e7tEATMAGIC:
10718 9 game->change_dmagic(-1*game->get_magicdrainrate());
10719 9 break;
10720
10721 case e7tEATRUPEES:
10722 game->change_drupy(-1);
10723 break;
10724 }
10725
10726 1089 clk2=0;
10727 1089 }
10728
10729
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 7312 times.
7873 if((clk&0x18)==8) // stop its animation on the middle frame
10730 7312 --clk;
10731 7873 }
10732
4/4
✓ Branch 0 taken 1056599 times.
✓ Branch 1 taken 14875053 times.
✓ Branch 2 taken 620077 times.
✓ Branch 3 taken 436522 times.
15931652 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10733 {
10734 // Movement engine
10735
6/6
✓ Branch 0 taken 844908 times.
✓ Branch 1 taken 14650222 times.
✓ Branch 2 taken 3399 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14646656 times.
✓ Branch 5 taken 59 times.
15495130 if(clk>=0) switch(id>>12)
10736 {
10737 case 0: // Normal movement
10738
10739 /*
10740 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10741 {
10742 // Overloading clk4 (Tribble clock) here...
10743 step=17/100.0;
10744 if(clk4<32) misc=1;
10745 else if(clk4<48) misc=2;
10746 else if(clk4<300) { misc=3; step = dstep/100.0; }
10747 else if(clk4<316) misc=2;
10748 else if(clk4<412) misc=1;
10749 else if(clk4<540) { misc=0; step=0; }
10750 else clk4=0;
10751 if(clk4==48) clk=0;
10752 hxofs=(misc>=2)?0:1000;
10753 if (dmisc9==e9tLEEVER)
10754 variable_walk(rate, homing, 0);
10755 else
10756 variable_walk_8(rate, homing, 4, 0);
10757 break;
10758 }
10759 */
10760
4/4
✓ Branch 0 taken 14267622 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13850546 times.
14646656 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10761 {
10762 796110 vire_hop();
10763 796110 break;
10764 }
10765
2/2
✓ Branch 0 taken 1061272 times.
✓ Branch 1 taken 12789274 times.
13850546 else if(dmisc9==e9tROPE) //Rope charge
10766 {
10767
9/10
✓ Branch 0 taken 1043850 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 153470 times.
✓ Branch 3 taken 890380 times.
✓ Branch 4 taken 141385 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 140560 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 140560 times.
1061272 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10768 {
10769
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 131484 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
140560 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10770 {
10771
10772
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10773 {
10774 14 hp=-1000;
10775
10776
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10777 {
10778
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10779 14 Ewpns.add(ew);
10780 14 ew->fakez = fakez;
10781
10782
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10783 {
10784 14 ew->step=0;
10785 14 ew->id=wpn+dmisc3;
10786 14 ew->misc=50;
10787 14 ew->clk=48;
10788 14 }
10789
10790 14 fired=true;
10791 14 }
10792 else
10793 {
10794 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10795 Ewpns.add(ew);
10796 ew->fakez = fakez;
10797
10798 if(wpn==ewSBomb || wpn==ewBomb)
10799 {
10800 ew->step=0;
10801 ew->id=wpn;
10802 ew->misc=50;
10803 ew->clk=48;
10804 }
10805
10806 fired=true;
10807 }
10808 14 }
10809
10810 else
10811 {
10812 33 hp=-1000;
10813
10814 int32_t wpn2;
10815
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10816 33 wpn2=wpn;
10817 else
10818 wpn2=wpn;
10819
10820
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10821 33 Ewpns.add(ew);
10822 33 ew->fakez = fakez;
10823
10824
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10825 {
10826 33 ew->step=0;
10827 33 ew->id=wpn2;
10828 33 ew->misc=50;
10829 33 ew->clk=48;
10830 33 }
10831
10832 33 fired=true;
10833 }
10834 47 }
10835 140560 }
10836
10837 1061272 charge_attack();
10838 1061272 break;
10839 }
10840 /*
10841 * Boomerang-throwers have a halt count of 1
10842 * Zols have a halt count of (zc_oldrand()&7)<<4
10843 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10844 * Everything else has 48
10845 */
10846 else
10847 {
10848
2/2
✓ Branch 0 taken 572383 times.
✓ Branch 1 taken 12216891 times.
12789274 if(wpn==ewBrang) // Goriya
10849 {
10850 572383 halting_walk(rate,homing,0,hrate, 1);
10851 572383 }
10852
4/4
✓ Branch 0 taken 12067291 times.
✓ Branch 1 taken 149600 times.
✓ Branch 2 taken 4783350 times.
✓ Branch 3 taken 7283941 times.
12216891 else if(dmisc9==e9tNORMAL && wpn==0)
10853 {
10854
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6565968 times.
7283941 if(dmisc2==e2tSPLITHIT) // Zol
10855 {
10856 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10857 717973 }
10858
4/4
✓ Branch 0 taken 1773827 times.
✓ Branch 1 taken 4792141 times.
✓ Branch 2 taken 1557936 times.
✓ Branch 3 taken 215891 times.
6565968 else if(frate<=8 && starting_hp==1) // Gel
10859 {
10860 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10861 215891 }
10862 else // Other
10863 {
10864 6350077 halting_walk(rate,homing,0,hrate, 48);
10865 }
10866 7283941 }
10867 else // Other
10868 {
10869 4932950 halting_walk(rate,homing,0,hrate, 48);
10870 }
10871 }
10872
10873 //if not in midair, and Hero's swinging sword is nearby, jump.
10874 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10875 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10876 {
10877 facehero(false);
10878 sclk=16+((dir^1)<<8);
10879 fall=-FEATHERJUMP;
10880 sfx(WAV_ZN1JUMP,pan(x));
10881 }*/
10882 12789274 break;
10883
10884 // Following cases are for just after creation-by-splitting.
10885 case 1:
10886
2/2
✓ Branch 0 taken 2555 times.
✓ Branch 1 taken 844 times.
3399 if(misc==1)
10887 {
10888 844 dir=up;
10889 844 step=8;
10890 844 }
10891
10892
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 2588 times.
3399 if(misc<=2)
10893 {
10894 2588 move(step);
10895
10896
2/2
✓ Branch 0 taken 2049 times.
✓ Branch 1 taken 539 times.
2588 if(!canmove(dir,(zfix)0,0,false))
10897 539 dir=down;
10898 2588 }
10899
10900
2/2
✓ Branch 0 taken 2588 times.
✓ Branch 1 taken 811 times.
3399 if(misc==3)
10901 {
10902
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 517 times.
811 if(canmove(right,(zfix)16,0,false))
10903 517 x+=16;
10904 811 }
10905
10906 3399 ++misc;
10907 3399 break;
10908
10909 case 2:
10910
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
10911 {
10912 15 dir=down;
10913 15 step=8;
10914 15 }
10915
10916
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
10917 {
10918 45 move(step);
10919 /*
10920 if(!canmove(dir,(zfix)0,0,false))
10921 dir=up;
10922 */
10923 45 }
10924
10925
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
10926 {
10927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
10928 14 x-=16;
10929 14 }
10930
10931 59 ++misc;
10932 59 break;
10933
10934 default:
10935
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
10936 {
10937 28 dir=(zc_oldrand()%4);
10938 28 step=8;
10939 28 }
10940
10941
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
10942 {
10943 83 move(step);
10944
10945
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
10946 2 dir=dir^1;
10947 83 }
10948
10949
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
10950 {
10951
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
10952 8 x+=(dir==left ? -16 : 16);
10953 25 }
10954
10955 108 ++misc;
10956 108 break;
10957 14650222 }
10958
10959
4/4
✓ Branch 0 taken 25806 times.
✓ Branch 1 taken 15469324 times.
✓ Branch 2 taken 24956 times.
✓ Branch 3 taken 850 times.
15495130 if(id>>12 && misc>=4) //recently spawned by a split enemy
10960 {
10961 850 id&=0xFFF;
10962 850 step = zslongToFix(dstep*100);
10963
10964
2/2
✓ Branch 0 taken 849 times.
✓ Branch 1 taken 1 times.
850 if(x<32) x=32;
10965
10966
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 24 times.
850 if(x>world_w-48) x=world_w-48;
10967
10968
2/2
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 26 times.
850 if(y<32) y=32;
10969
10970
2/2
✓ Branch 0 taken 843 times.
✓ Branch 1 taken 7 times.
850 if(y>world_h-48) y=world_h-48;
10971
10972 850 misc=3;
10973 850 }
10974 15495130 }
10975 else
10976 {
10977 //sfx(wpnsfx(wpn),pan(x));
10978
1/2
✓ Branch 0 taken 436522 times.
✗ Branch 1 not taken.
436522 if(clk2>2) clk2--;
10979 }
10980
10981 // Fire Zol
10982
8/8
✓ Branch 0 taken 6346424 times.
✓ Branch 1 taken 9593101 times.
✓ Branch 2 taken 174420 times.
✓ Branch 3 taken 6172004 times.
✓ Branch 4 taken 1375 times.
✓ Branch 5 taken 173045 times.
✓ Branch 6 taken 1334 times.
✓ Branch 7 taken 41 times.
15939525 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
10983 {
10984 1334 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
10985 1334 sfx(wpnsfx(wpn),pan(x));
10986
10987 1334 int32_t i=Ewpns.Count()-1;
10988 1334 weapon *ew = (weapon*)(Ewpns.spr(i));
10989
10990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1334 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
10991 {
10992 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
10993 if ( ew->do_animation ) ew->tile+=ew->aframe;
10994 }
10995 1334 }
10996 // Goriya
10997
14/16
✓ Branch 0 taken 1056599 times.
✓ Branch 1 taken 14881592 times.
✓ Branch 2 taken 472320 times.
✓ Branch 3 taken 584279 times.
✓ Branch 4 taken 459560 times.
✓ Branch 5 taken 12760 times.
✓ Branch 6 taken 426583 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 426583 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 423842 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 423842 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 417426 times.
✓ Branch 15 taken 6416 times.
15938191 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
10998 {
10999 6416 misc=index+100;
11000
7/14
✓ Branch 0 taken 6416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6416 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6416 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6416 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6416 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6416 times.
✗ Branch 13 not taken.
6416 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11001 6416 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11002
11003
2/2
✓ Branch 0 taken 6159 times.
✓ Branch 1 taken 257 times.
6416 if(dmisc1==2)
11004 {
11005 257 int32_t ndir=dir;
11006
11007
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11008 {
11009 6 ndir=(Hero.y+8<y)?up:down;
11010 6 }
11011 else //turn to face Hero
11012 {
11013 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11014 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11015
11016
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11017 {
11018 13 ndir=down;
11019 13 }
11020
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11021 {
11022 68 ndir=right;
11023 68 }
11024
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11025 {
11026 48 ndir=up;
11027 48 }
11028 else
11029 {
11030 122 ndir=left;
11031 }
11032 }
11033
11034 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11035
11036
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11037 {
11038 223 dir=ndir;
11039 223 }
11040 257 }
11041 6416 }
11042
15/16
✓ Branch 0 taken 15870915 times.
✓ Branch 1 taken 60860 times.
✓ Branch 2 taken 223166 times.
✓ Branch 3 taken 15708609 times.
✓ Branch 4 taken 196679 times.
✓ Branch 5 taken 26487 times.
✓ Branch 6 taken 171787 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 170382 times.
✓ Branch 9 taken 1405 times.
✓ Branch 10 taken 155282 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 155282 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 154338 times.
15931775 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11043
3/3
✓ Branch 0 taken 27446 times.
✓ Branch 1 taken 125986 times.
✓ Branch 2 taken 906 times.
154338 switch(dmisc1)
11044 {
11045 case e1tCONSTANT: //Deathnut
11046 {
11047 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11048
2/2
✓ Branch 0 taken 123398 times.
✓ Branch 1 taken 2588 times.
125986 if(clk5>64)
11049 {
11050 2588 clk5=0;
11051 2588 fired=false;
11052 2588 }
11053
11054 125986 clk5+=(zc_oldrand()&3);
11055
11056
4/4
✓ Branch 0 taken 76865 times.
✓ Branch 1 taken 49121 times.
✓ Branch 2 taken 25698 times.
✓ Branch 3 taken 51167 times.
125986 if((clk5>24)&&(clk5<52))
11057 {
11058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51167 times.
51167 if ( do_animation )tile+=20; //firing
11059
11060
4/4
✓ Branch 0 taken 28011 times.
✓ Branch 1 taken 23156 times.
✓ Branch 2 taken 25178 times.
✓ Branch 3 taken 2833 times.
51167 if(!fired&&(clk5>=38))
11061 {
11062
5/10
✓ Branch 0 taken 2833 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2833 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2833 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2833 times.
✗ Branch 9 not taken.
2833 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11063 2833 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11064 2833 sfx(wpnsfx(wpn),pan(x));
11065 2833 fired=true;
11066 2833 }
11067 51167 }
11068
11069 125986 break;
11070 }
11071
11072 case e1tFIREOCTO: //Fire Octo
11073 906 timer=zc_oldrand()%50+50;
11074 906 break;
11075
11076 default:
11077 27446 FireWeapon();
11078 27446 break;
11079 154338 }
11080
11081 /* Fire again if:
11082 * - clk2 about to run out
11083 * - not already double-firing (dmisc1 is 1)
11084 * - not carrying Hero
11085 * - one in 0xF chance
11086 */
11087
8/10
✓ Branch 0 taken 530545 times.
✓ Branch 1 taken 15408980 times.
✓ Branch 2 taken 4567 times.
✓ Branch 3 taken 525978 times.
✓ Branch 4 taken 4567 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4567 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4277 times.
✓ Branch 9 taken 290 times.
15939525 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11088 {
11089 #if 1
11090 290 newdir(rate, homing, grumble);
11091 #else
11092 dir^=2;
11093 #endif
11094 290 clk2=28;
11095 290 ++multishot;
11096 290 }
11097
11098
2/2
✓ Branch 0 taken 3594397 times.
✓ Branch 1 taken 12345128 times.
15939525 if(clk2==0)
11099 {
11100 12345128 multishot = 0;
11101 12345128 }
11102
11103
2/2
✓ Branch 0 taken 15875215 times.
✓ Branch 1 taken 64310 times.
15939525 if(timer) //Fire Octo
11104 {
11105 64310 clk2=15; //this keeps the octo in place until he's done firing
11106
11107
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11108 {
11109 15752 FireBreath(false);
11110 15752 }
11111
11112 64310 --timer;
11113 64310 }
11114
11115
2/2
✓ Branch 0 taken 15690132 times.
✓ Branch 1 taken 249393 times.
15939525 if(dmisc2==e2tTRIBBLE)
11116 249393 ++clk4;
11117
11118
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15935045 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15938832 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15939525 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11119 {
11120 693 int32_t kids = guys.Count();
11121 693 int32_t id2=dmisc3;
11122
11123
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11124 {
11125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11126 {
11127
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11128 {
11129 int guycarryingitem = guys.Count()-1;
11130 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11131 itemguy = false;
11132 }
11133
11134 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11135 693 }
11136 693 }
11137
11138
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11139 {
11140 Hero.setEaten(0);
11141 hashero=false;
11142 }
11143
11144 693 stop_bgsfx(index);
11145 693 return true;
11146 }
11147
11148 15938832 return enemy::animate(index);
11149 16383593 }
11150
11151 16837213 void eStalfos::draw(BITMAP *dest)
11152 {
11153 16837213 update_enemy_frame();
11154
11155
8/8
✓ Branch 0 taken 16836290 times.
✓ Branch 1 taken 923 times.
✓ Branch 2 taken 16834946 times.
✓ Branch 3 taken 1344 times.
✓ Branch 4 taken 87435 times.
✓ Branch 5 taken 16747511 times.
✓ Branch 6 taken 76320 times.
✓ Branch 7 taken 11115 times.
16837213 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11156 {
11157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11158 11115 }
11159
11160 16837213 enemy::draw(dest);
11161 16837213 }
11162
11163 8111423 bool eStalfos::can_drawshadow() const
11164 {
11165 8111423 return enemy::can_drawshadow();
11166 }
11167 8111423 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11168 {
11169 8111423 int32_t tempy=yofs;
11170
11171
4/4
✓ Branch 0 taken 7896005 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7799804 times.
✓ Branch 3 taken 311619 times.
8111423 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11172 {
11173 311619 flip = 0;
11174 311619 int32_t fdiv = frate/4;
11175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11176
11177
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11178 311619 efrate:((clk>=(frate>>1))?1:0);
11179 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11180
11181
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11182 {
11183 311619 shadowtile+=f2;
11184 311619 }
11185 else
11186 {
11187 shadowtile+=f2?1:0;
11188 }
11189
11190 311619 yofs+=shadowdistance;
11191 311619 yofs+=8;
11192 311619 }
11193
4/4
✓ Branch 0 taken 7896005 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 8108388 times.
✓ Branch 3 taken 3035 times.
8111423 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11194 {
11195 3035 flip = 0;
11196 3035 int32_t fdiv = frate/4;
11197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11198
11199
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11200 3035 efrate:((clk>=(frate>>1))?1:0);
11201 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11202
11203
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11204 {
11205 3035 shadowtile+=f2;
11206 3035 }
11207 else
11208 {
11209 shadowtile+=f2?1:0;
11210 }
11211 3035 }
11212 8111423 enemy::drawshadow(dest, translucent);
11213 8111423 yofs=tempy;
11214 8111423 }
11215
11216 160669 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11217 {
11218 160669 int32_t wpnId = w->id;
11219 160669 int32_t wpnDir = w->dir;
11220
11221
4/4
✓ Branch 0 taken 1453 times.
✓ Branch 1 taken 159216 times.
✓ Branch 2 taken 631 times.
✓ Branch 3 taken 822 times.
160669 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11222
6/8
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 407 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 276 times.
✓ Branch 5 taken 131 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 131 times.
631 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11223
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 131 times.
131 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11224 {
11225 276 shield = false;
11226 276 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11227
11228
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 254 times.
276 if(get_qr(qr_BRKNSHLDTILES))
11229 254 o_tile=s_tile;
11230 276 }
11231
11232 160669 int32_t ret = enemy::takehit(w,realweap);
11233
11234
4/4
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 137144 times.
✓ Branch 2 taken 21774 times.
✓ Branch 3 taken 1751 times.
160669 if(sclk && dmisc2==e2tSPLITHIT)
11235 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11236
11237 160669 return ret;
11238 }
11239
11240 1061272 void eStalfos::charge_attack()
11241 {
11242
2/2
✓ Branch 0 taken 8516 times.
✓ Branch 1 taken 1052756 times.
1061272 if(slide())
11243 8516 return;
11244
11245
10/12
✓ Branch 0 taken 1052756 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1050352 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 1020716 times.
✓ Branch 5 taken 29636 times.
✓ Branch 6 taken 999163 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 992627 times.
✓ Branch 9 taken 6536 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 992627 times.
1052756 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11246 60129 return;
11247
11248
2/2
✓ Branch 0 taken 40922 times.
✓ Branch 1 taken 951705 times.
992627 if(clk3<=0)
11249 {
11250 40922 fix_coords(true);
11251
11252
2/2
✓ Branch 0 taken 11132 times.
✓ Branch 1 taken 29790 times.
40922 if(!dashing)
11253 {
11254 29790 int32_t ldir = lined_up(7,false);
11255
11256
4/4
✓ Branch 0 taken 3397 times.
✓ Branch 1 taken 26393 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 2905 times.
29790 if(ldir!=-1 && canmove(ldir,false))
11257 {
11258 2905 dir=ldir;
11259 2905 dashing=true;
11260
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2905 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2905 if (dmisc10<=0 || replay_version_check(0,33) || get_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE))
11261 2905 step=zslongToFix(dstep*100)+1;
11262 else
11263 step=zslongToFix(dmisc10*100);
11264 2905 }
11265 26885 else newdir(4,0,0);
11266 29790 }
11267
11268
2/2
✓ Branch 0 taken 39330 times.
✓ Branch 1 taken 1592 times.
40922 if(!canmove(dir,false))
11269 {
11270 1592 step=zslongToFix(dstep*100);
11271 1592 newdir();
11272 1592 dashing=false;
11273 1592 }
11274
11275 40922 zfix div = step;
11276
11277
1/2
✓ Branch 0 taken 40922 times.
✗ Branch 1 not taken.
40922 if(div == 0)
11278 div = 1;
11279
11280 40922 clk3=(int32_t)(16.0/div);
11281 40922 return;
11282 }
11283
11284 951705 move(step);
11285 951705 --clk3;
11286 1061272 }
11287
11288 796110 void eStalfos::vire_hop()
11289 {
11290
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11291 {
11292
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11293 {
11294
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11295 3843 }
11296 376292 }
11297 417076 else sclk=0;
11298
11299
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11300 31892 return;
11301
11302 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11303 int32_t jump_height;
11304
11305
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11306 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11307 else jump_height = dmisc10;
11308
11309 761476 y=floor_y;
11310
11311
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11312 {
11313 26258 fix_coords();
11314
11315 //z=0;
11316 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11317 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11318
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11319 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11320
11321
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11322 {
11323 //z=0;
11324
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11325 {
11326
11327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11328 17258 }
11329 21336 }
11330
11331
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11332 {
11333 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11334 7030 }
11335
11336 26258 clk3=int32_t(16.0/step.getFloat());
11337 26258 }
11338
11339 761476 --clk3;
11340
11341
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11342 761476 move(step);
11343
11344 761476 floor_y=y;
11345 761476 clk2--;
11346
11347 //if we're in the middle of a jump
11348
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11349 {
11350 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11351
11352
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11353 {
11354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11355 93147 else z=h;
11356 93147 }
11357 else
11358 {
11359 384731 y=floor_y-h;
11360 384731 shadowdistance=h;
11361 }
11362 477878 }
11363 else
11364 283598 shadowdistance = 0;
11365 796110 }
11366
11367 143 void eStalfos::eathero()
11368 {
11369
5/8
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 74 times.
143 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11370 {
11371 74 hashero=true;
11372 74 y=floor_y;
11373 74 z=0;
11374
11375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(Hero.isSwimming())
11376 {
11377 Hero.setX(x);
11378 Hero.setY(y);
11379 }
11380 else
11381 {
11382 74 x=Hero.getX();
11383 74 y=Hero.getY();
11384 }
11385
11386 74 clk2=0;
11387 74 }
11388 143 }
11389
11390 1480441 bool eStalfos::WeaponOut()
11391 {
11392
2/2
✓ Branch 0 taken 2414454 times.
✓ Branch 1 taken 626493 times.
3040947 for(int32_t i=0; i<Ewpns.Count(); i++)
11393 {
11394
3/4
✓ Branch 0 taken 853948 times.
✓ Branch 1 taken 1560506 times.
✓ Branch 2 taken 853948 times.
✗ Branch 3 not taken.
2414454 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11395 {
11396 853948 return true;
11397 }
11398 1560506 }
11399
11400 626493 return false;
11401 1480441 }
11402
11403 369776 void eStalfos::KillWeapon()
11404 {
11405
2/2
✓ Branch 0 taken 316707 times.
✓ Branch 1 taken 369776 times.
686483 for(int32_t i=0; i<Ewpns.Count(); i++)
11406 {
11407
4/4
✓ Branch 0 taken 267955 times.
✓ Branch 1 taken 48752 times.
✓ Branch 2 taken 267137 times.
✓ Branch 3 taken 818 times.
316707 if(((weapon*)Ewpns.spr(i))->level==misc && Ewpns.spr(i)->id==ewBrang)
11408 {
11409 //only kill this Goriya's boomerang -DD
11410
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 419 times.
818 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11411 {
11412 419 Ewpns.del(i);
11413 419 }
11414 818 }
11415 316707 }
11416 369776 }
11417
11418 void eStalfos::break_shield()
11419 {
11420 if(!shield)
11421 return;
11422
11423 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11424 shield=false;
11425
11426 if(get_qr(qr_BRKNSHLDTILES))
11427 o_tile=s_tile;
11428 }
11429
11430 void eStalfos::repair_shield()
11431 {
11432 if (shield)
11433 return;
11434
11435 shield = true;
11436
11437 if (get_qr(qr_BRKNSHLDTILES))
11438 {
11439 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11440 else o_tile = d->tile;
11441 }
11442 }
11443
11444 14406 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11445 14406 {
11446
1/2
✓ Branch 0 taken 14406 times.
✗ Branch 1 not taken.
14406 dir=(zc_oldrand()&7)+8;
11447
1/2
✓ Branch 0 taken 14406 times.
✗ Branch 1 not taken.
14406 step=0;
11448 14406 movestatus=1;
11449
3/4
✓ Branch 0 taken 11247 times.
✓ Branch 1 taken 3159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11247 times.
14406 if (dmisc1 != 1 && dmisc19 > 0)
11450 {
11451 step = dmisc19/100.0;
11452 movestatus = 1;
11453 }
11454
1/2
✓ Branch 0 taken 14406 times.
✗ Branch 1 not taken.
14406 if (dmisc1 == 2) movestatus=2;
11455 14406 c=0;
11456 14406 clk4=0;
11457 //nets;
11458
1/2
✓ Branch 0 taken 14406 times.
✗ Branch 1 not taken.
14406 init_size_flags();
11459 14406 dummy_int[1]=0;
11460 14406 }
11461
11462 3691183 bool eKeese::animate(int32_t index)
11463 {
11464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3691183 times.
3691183 if(switch_hooked) return enemy::animate(index);
11465
2/4
✓ Branch 0 taken 3691183 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3691183 times.
3691183 if(fallclk||drownclk) return enemy::animate(index);
11466
2/2
✓ Branch 0 taken 131109 times.
✓ Branch 1 taken 3560074 times.
3691183 if(dying)
11467 131109 return Dead(index);
11468
11469
2/2
✓ Branch 0 taken 3532905 times.
✓ Branch 1 taken 27169 times.
3560074 if(clk==0)
11470 {
11471 27169 removearmos(x,y);
11472 27169 }
11473
11474
2/2
✓ Branch 0 taken 1037646 times.
✓ Branch 1 taken 2522428 times.
3560074 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11475 {
11476 1037646 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11477 1037646 }
11478 else
11479 {
11480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2522428 times.
2522428 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11481 2522428 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11482 }
11483
11484
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3439736 times.
3560074 if(dmisc2 == e2tKEESETRIB)
11485 {
11486
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11487 {
11488
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11489 {
11490 105 int32_t kids = guys.Count();
11491 105 bool success = false;
11492 105 int32_t id2=dmisc3;
11493 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11494
11495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11496 {
11497
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11498 {
11499 int guycarryingitem = guys.Count()-1;
11500 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11501 itemguy = false;
11502 }
11503
11504 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11505 105 }
11506
11507 105 stop_bgsfx(index);
11508 105 return true;
11509 }
11510 else
11511 {
11512 86 clk4=0;
11513 }
11514 86 }
11515 120233 }
11516 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11517
3/4
✓ Branch 0 taken 995121 times.
✓ Branch 1 taken 2444615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 995121 times.
3439736 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11518 {
11519
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 308053 times.
995121 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11520 {
11521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11522 {
11523 fakez=int32_t(step/zslongToFix(dstep*100));
11524 // Some variance in keese flight heights when away from Hero
11525 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11526
11527 }
11528 else
11529 {
11530 687068 z=int32_t(step/zslongToFix(dstep*100));
11531 // Some variance in keese flight heights when away from Hero
11532
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11533 }
11534 687068 }
11535 else
11536 {
11537
2/2
✓ Branch 0 taken 149242 times.
✓ Branch 1 taken 158811 times.
308053 if (moveflags & move_use_fake_z)
11538 {
11539 149242 fakez=int32_t(step/zslongToFix(dstep*100));
11540 // Some variance in keese flight heights when away from Hero
11541
2/2
✓ Branch 0 taken 132535 times.
✓ Branch 1 taken 16707 times.
149242 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11542
11543 149242 }
11544 else
11545 {
11546 158811 z=int32_t(step/zslongToFix(dstep*100));
11547 // Some variance in keese flight heights when away from Hero
11548
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11549 }
11550 }
11551 995121 }
11552
11553 3559969 return enemy::animate(index);
11554 3691183 }
11555
11556 2931678 bool eKeese::can_drawshadow() const
11557 {
11558
4/4
✓ Branch 0 taken 1533960 times.
✓ Branch 1 taken 1397718 times.
✓ Branch 2 taken 17822 times.
✓ Branch 3 taken 1516138 times.
2931678 if(get_qr(qr_ENEMIESZAXIS) && step <= 0)
11559 17822 return false;
11560
11561 2913856 return enemy::can_drawshadow();
11562 2931678 }
11563 2246724 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11564 {
11565 2246724 flip = 0;
11566
2/2
✓ Branch 0 taken 1561770 times.
✓ Branch 1 taken 684954 times.
2246724 if(!can_drawshadow())
11567 1561770 return;
11568 684954 int32_t tempy=yofs;
11569 684954 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11570
11571
2/2
✓ Branch 0 taken 166228 times.
✓ Branch 1 taken 518726 times.
684954 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 684954 times.
684954 if(!get_qr(qr_ENEMIESZAXIS))
11573 {
11574 yofs+=int32_t(step/zslongToFix(dstep*10));
11575 }
11576
11577 684954 enemy::drawshadow(dest, translucent);
11578 684954 yofs=tempy;
11579 2246724 }
11580
11581 8413799 void eKeese::draw(BITMAP *dest)
11582 {
11583 8413799 update_enemy_frame();
11584 8413799 enemy::draw(dest);
11585 8413799 }
11586
11587 14406 void eKeese::init_size_flags()
11588 {
11589 14406 SIZEflags = d->SIZEflags;
11590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14406 times.
14406 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11591
1/2
✓ Branch 0 taken 14406 times.
✗ Branch 1 not taken.
14406 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11592
11593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14406 times.
14406 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11594
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14406 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14406 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11595
11596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14406 times.
14406 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11597
1/2
✓ Branch 0 taken 14406 times.
✗ Branch 1 not taken.
14406 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11598
11599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14406 times.
14406 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11600
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14406 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14406 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11601
11602
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14406 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14406 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11603 // al_trace("Enemy txsz:%i\n", txsz);
11604
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14406 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14406 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11605
11606
11607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14406 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14406 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11608
11609
1/2
✓ Branch 0 taken 14406 times.
✗ Branch 1 not taken.
14406 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11610
1/2
✓ Branch 0 taken 14406 times.
✗ Branch 1 not taken.
14406 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11611 {
11612 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11613 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11614 }
11615
11616
1/2
✓ Branch 0 taken 14406 times.
✗ Branch 1 not taken.
14406 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11617 14406 }
11618
11619 20171 void eWizzrobe::submerge(bool set)
11620 {
11621
2/2
✓ Branch 0 taken 20024 times.
✓ Branch 1 taken 147 times.
20171 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11622 {
11623 20024 hxofs = set?1000:0;
11624 20024 return;
11625 }
11626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11627 147 submerged = set;
11628
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11629 76 hxofs+=1000;
11630 71 else hxofs -= 1000;
11631 20171 }
11632 5350 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11633 5350 {
11634 5350 hxofs = 0;
11635 5350 submerged = false;
11636
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 switch(dmisc1)
11637 {
11638 case 0:
11639 2992 submerge(true);
11640 2992 fading=fade_invisible;
11641 // Set clk to just before the 'reappear' threshold
11642
9/10
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2991 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1808 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1807 times.
✓ Branch 9 taken 1 times.
2992 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11643 2992 break;
11644
11645 default:
11646 2358 dir=(loadside==right)?right:left;
11647 2358 misc=-3;
11648 2358 break;
11649 }
11650
11651 //netst+2880;
11652 5350 charging=false;
11653 5350 firing=false;
11654 5350 fclk=0;
11655
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11656
1/4
✓ Branch 0 taken 5350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5350 if (SIZEflags != 0) init_size_flags();;
11657 5350 }
11658
11659 2081613 bool eWizzrobe::animate(int32_t index)
11660 {
11661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2081613 times.
2081613 if(switch_hooked) return enemy::animate(index);
11662
2/4
✓ Branch 0 taken 2081613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2081613 times.
2081613 if(fallclk||drownclk) return enemy::animate(index);
11663
2/2
✓ Branch 0 taken 38023 times.
✓ Branch 1 taken 2043590 times.
2081613 if(dying)
11664 {
11665 38023 return Dead(index);
11666 }
11667
11668
2/2
✓ Branch 0 taken 1976944 times.
✓ Branch 1 taken 66646 times.
2043590 if(clk==0)
11669 {
11670 66646 removearmos(x,y);
11671 66646 }
11672
11673
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1024370 times.
2043590 if(dmisc1) // Floating
11674 {
11675 1019220 wizzrobe_attack();
11676 1019220 }
11677 else // Teleporting
11678 {
11679
5/6
✓ Branch 0 taken 1017286 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1006199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024370 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11680 {
11681 7084 fading=0;
11682 7084 submerge(false);
11683 7084 solid_update(false);
11684 7084 }
11685
8/8
✓ Branch 0 taken 983365 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 5313 times.
✓ Branch 3 taken 5151 times.
✓ Branch 4 taken 5006 times.
✓ Branch 5 taken 4247 times.
✓ Branch 6 taken 4109 times.
✓ Branch 7 taken 3855 times.
1017286 else switch(clk)
11686 {
11687 case 0:
11688
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5123 times.
6240 if(!dmisc2)
11689 {
11690 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11691 // but should not appear on dungeon walls.
11692
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4710 times.
5123 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11693
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4486 times.
4710 else if (editorflags&ENEMY_FLAG5)
11694 {
11695 //2.10 Windrobe
11696 //randomise location and face Hero
11697 224 int32_t t=0;
11698 224 bool placed=false;
11699
11700
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11701 {
11702
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11703 {
11704 280 x=((zc_oldrand()%12)+2)*16;
11705 280 y=((zc_oldrand()%7)+2)*16;
11706 280 }
11707 else
11708 {
11709 87 x=((zc_oldrand()%14)+1)*16;
11710 87 y=((zc_oldrand()%9)+1)*16;
11711 }
11712
11713 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11714
11715
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11716 {
11717 224 placed=true;
11718 224 }
11719
11720 367 ++t;
11721 }
11722
11723
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11724 {
11725
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11726 {
11727 47 dir=down;
11728 47 }
11729 else
11730 {
11731 14 dir=up;
11732 }
11733 61 }
11734 else
11735 {
11736
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11737 {
11738 72 dir=right;
11739 72 }
11740 else
11741 {
11742 91 dir=left;
11743 }
11744 }
11745
11746
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11747 return true;
11748
11749
11750 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11751 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11752 224 }
11753 4486 else place_on_axis(true, dmisc4!=0);
11754 5123 }
11755 else
11756 {
11757 1117 int32_t t=0;
11758 1117 bool placed=false;
11759
11760
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11761 {
11762
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11763 {
11764 1340 x=((zc_oldrand()%12)+2)*16;
11765 1340 y=((zc_oldrand()%7)+2)*16;
11766 1340 }
11767 else
11768 {
11769 1103 x=((zc_oldrand()%14)+1)*16;
11770 1103 y=((zc_oldrand()%9)+1)*16;
11771 }
11772
11773 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11774
11775
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11776 {
11777 1117 placed=true;
11778 1117 }
11779
11780 2443 ++t;
11781 }
11782
11783
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11784 {
11785
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11786 {
11787 238 dir=down;
11788 238 }
11789 else
11790 {
11791 148 dir=up;
11792 }
11793 386 }
11794 else
11795 {
11796
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11797 {
11798 340 dir=right;
11799 340 }
11800 else
11801 {
11802 391 dir=left;
11803 }
11804 }
11805
11806
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11807 return true;
11808 }
11809
11810 6240 fading=fade_flicker;
11811 6240 submerge(false);
11812 6240 solid_update(false);
11813 6240 break;
11814
11815 case 64:
11816 5313 fading=0;
11817 5313 charging=true;
11818 5313 break;
11819
11820 case 73:
11821 5151 charging=false;
11822 5151 firing=40;
11823 5151 break;
11824
11825 case 83:
11826 5006 wizzrobe_attack_for_real();
11827 5006 break;
11828
11829 case 119:
11830 4247 firing=false;
11831 4247 charging=true;
11832 4247 break;
11833
11834 case 128:
11835 4109 fading=fade_flicker;
11836 4109 charging=false;
11837 4109 break;
11838
11839 case 146:
11840 3855 fading=fade_invisible;
11841 3855 submerge(true);
11842 3855 solid_update(false);
11843
11844 [[fallthrough]];
11845 default:
11846
4/4
✓ Branch 0 taken 987060 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980971 times.
✓ Branch 3 taken 6249 times.
987220 if(clk>=(146+zc_max(0,dmisc5)))
11847 6249 clk=-1;
11848
11849 987220 break;
11850 }
11851 }
11852
11853 2043590 return enemy::animate(index);
11854 2081613 }
11855
11856 7929 void eWizzrobe::wizzrobe_attack_for_real()
11857 {
11858
1/2
✓ Branch 0 taken 7929 times.
✗ Branch 1 not taken.
7929 if(wpn==0) // Edited enemies
11859 return;
11860
11861
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5946 times.
7929 if(dmisc2 == 0) //normal weapon
11862 {
11863 5946 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11864 5946 sfx(firesfx, pan(x));
11865 5946 }
11866
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11867 {
11868 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11869 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11870 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11871 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11872 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11873 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11874 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11875 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11876 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11877 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11878 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11879 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11880 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11881 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11882 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11883 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11884 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
11885 //i've compromised by making all old quest use this code chunk by default.
11886
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
11887 {
11888 995 sfx(WAV_FIRE, pan(x));
11889
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(x));
11890 else
11891 {
11892
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
11893 {
11894 19 case ewFireball: sfx(40, pan(x)); break;
11895 case ewBrang: sfx(4, pan(x)); break; //Ghost.zh has 0?
11896 case ewSword: sfx(20, pan(x)); break; //Ghost.zh has 0?
11897 case ewRock: sfx(51, pan(x)); break;
11898 68 case ewMagic: sfx(32, pan(x)); break;
11899 case ewBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11900 case ewSBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11901 case ewLitBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11902 case ewLitSBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11903 case ewFireTrail: sfx(13, pan(x)); break;
11904 420 case ewFlame: sfx(13, pan(x)); break;
11905 case ewWind: sfx(32, pan(x)); break;
11906 case ewFlame2: sfx(13, pan(x)); break;
11907 case ewFlame2Trail: sfx(13, pan(x)); break;
11908 case ewIce: sfx(44, pan(x)); break;
11909 case ewFireball2: sfx(40, pan(x)); break; //fireball (rising)
11910 default: sfx(WAV_FIRE, pan(x)); break;
11911 }
11912 }
11913 995 }
11914 else
11915 {
11916 sfx(firesfx, pan(x));
11917 }
11918 995 }
11919
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
11920 {
11921 971 int32_t bc=0;
11922
11923
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
11924 {
11925
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
11926 {
11927 5195 ++bc;
11928 5195 }
11929 10497 }
11930
11931
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
11932 {
11933 963 int32_t kids = guys.Count();
11934 963 int32_t bats=(zc_oldrand()%3)+1;
11935
11936
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
11937 {
11938 // Summon bats (or anything)
11939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this))
11940 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11941 1965 }
11942 963 sfx(firesfx, pan(x));
11943 963 }
11944 971 }
11945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
11946 {
11947
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
11948 {
11949 return;
11950 }
11951
11952 17 int32_t kids = guys.Count();
11953
11954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
11955 {
11956 17 int32_t newguys=(zc_oldrand()%3)+1;
11957 17 bool summoned=false;
11958
11959
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
11960 {
11961 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
11962 32 int32_t x2=0;
11963 32 int32_t y2=0;
11964
11965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
11966 {
11967 36 x2=16*((zc_oldrand()%12)+2);
11968 36 y2=16*((zc_oldrand()%7)+2);
11969
11970
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
11971 {
11972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
11973 {
11974 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11975
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
11976 {
11977 ((enemy*)guys.spr(kids+i))->fakez = 64;
11978 ((enemy*)guys.spr(kids+i))->z = 0;
11979 }
11980 32 }
11981
11982 32 summoned=true;
11983 32 break;
11984 }
11985 4 }
11986 32 }
11987
11988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
11989 {
11990 17 sfx(firesfx, pan(x));
11991 17 }
11992 17 }
11993 17 }
11994 7929 }
11995
11996
11997 1019220 void eWizzrobe::wizzrobe_attack()
11998 {
11999
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12000 86341 return;
12001
12002
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12003 {
12004 39538 fix_coords();
12005
12006
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12007 {
12008 case 1: //walking
12009
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12010 2644 misc=0;
12011 else
12012 {
12013 10364 clk3=16;
12014
12015
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12016 {
12017 1398 wizzrobe_newdir(0);
12018 1398 }
12019 }
12020
12021 13008 break;
12022
12023 case 2: //phasing
12024 {
12025 3903 int32_t jx=x;
12026 3903 int32_t jy=y;
12027 3903 int32_t jdir=-1;
12028
12029
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12030 {
12031 case 0:
12032 484 jx-=32;
12033 484 jy-=32;
12034 484 jdir=15;
12035 484 break;
12036
12037 case 1:
12038 472 jx+=32;
12039 472 jy-=32;
12040 472 jdir=9;
12041 472 break;
12042
12043 case 2:
12044 482 jx+=32;
12045 482 jy+=32;
12046 482 jdir=11;
12047 482 break;
12048
12049 case 3:
12050 492 jx-=32;
12051 492 jy+=32;
12052 492 jdir=13;
12053 492 break;
12054 }
12055
12056
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12057 {
12058 1140 misc=3;
12059 1140 clk3=32;
12060 1140 dir=jdir;
12061 1140 break;
12062 }
12063 2763 }
12064 [[fallthrough]];
12065 case 3:
12066 3813 dir&=3;
12067 3813 misc=0;
12068 [[fallthrough]];
12069 case 0:
12070 19894 wizzrobe_newdir(64);
12071 [[fallthrough]];
12072 default:
12073
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12074 {
12075
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12076 {
12077 3265 misc=1;
12078 3265 clk3=16;
12079 3265 }
12080 else
12081 {
12082 239 wizzrobe_newdir(64);
12083 239 misc=0;
12084 239 clk3=32;
12085 }
12086 3504 }
12087 else
12088 {
12089 21886 clk3=32;
12090 }
12091
12092 25390 break;
12093 }
12094
12095
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12096 4478 ++misc;
12097 39538 }
12098
12099 932879 --clk3;
12100
12101
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12102 {
12103 case 1:
12104 case 3:
12105 248377 step=1;
12106 248377 break;
12107
12108 case 2:
12109 63903 step=0;
12110 63903 break;
12111
12112 default:
12113 620599 step=0.5;
12114 620599 break;
12115
12116 }
12117
12118 932879 move(step);
12119
12120 // if(d->misc1 && misc<=0 && clk3==28)
12121
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12122 {
12123
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12124 {
12125
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12126 {
12127 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12128 // sfx(WAV_WAND,pan(x));
12129 1928 wizzrobe_attack_for_real();
12130 1928 fclk=30;
12131 1928 }
12132 16835 }
12133 else
12134 {
12135
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12136 {
12137 995 wizzrobe_attack_for_real();
12138 995 fclk=30;
12139 995 }
12140 }
12141 21547 }
12142
12143
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12144 4050 misc=2;
12145
12146
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12147 3441 fix_coords();
12148
12149
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12150 {
12151
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12152 {
12153 83282 --fclk;
12154 83282 }
12155 932879 }
12156
12157 1019220 }
12158
12159 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12160 {
12161 // Wizzrobes shouldn't move to the edge of the screen;
12162 // if they're already there, they should move toward the center
12163
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12164 33 dir=right;
12165
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=world_w-32)
12166 4 dir=left;
12167
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12168 2 dir=down;
12169
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=world_h-32)
12170 5 dir=up;
12171 else
12172 21487 newdir(4,homing,spw_wizzrobe);
12173 21531 }
12174
12175 2099229 void eWizzrobe::draw(BITMAP *dest)
12176 {
12177 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12178
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1056746 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2099229 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12179 125018 return;
12180
12181 1974211 int32_t tempint=dummy_int[1];
12182 1974211 bool tempbool1=dummy_bool[1];
12183 1974211 bool tempbool2=dummy_bool[2];
12184 1974211 dummy_int[1]=fclk;
12185 1974211 dummy_bool[1]=charging;
12186 1974211 dummy_bool[2]=firing;
12187 1974211 update_enemy_frame();
12188 1974211 dummy_int[1]=tempint;
12189 1974211 dummy_bool[1]=tempbool1;
12190 1974211 dummy_bool[2]=tempbool2;
12191 1974211 enemy::draw(dest);
12192 2099229 }
12193
12194 209 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12195 209 {
12196 209 fading=fade_flash_die;
12197
6/8
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 50 times.
209 if(dir==down&&y>=128)
12198 {
12199 4 dir=up;
12200 4 }
12201
12202
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
209 if(dir==right&&x>=208)
12203 {
12204 dir=left;
12205 }
12206
1/4
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
209 if (SIZEflags != 0) init_size_flags();;
12207 209 }
12208
12209 133094 bool eDodongo::animate(int32_t index)
12210 {
12211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133094 times.
133094 if(switch_hooked) return enemy::animate(index);
12212
2/2
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 129040 times.
133094 if(dying)
12213 {
12214 4054 return Dead(index);
12215 }
12216
12217
2/2
✓ Branch 0 taken 128441 times.
✓ Branch 1 taken 599 times.
129040 if(clk==0)
12218 {
12219 599 removearmos(x,y);
12220 599 }
12221
12222
2/2
✓ Branch 0 taken 11424 times.
✓ Branch 1 taken 117616 times.
129040 if(clk2) // ate a bomb
12223 {
12224
2/2
✓ Branch 0 taken 11305 times.
✓ Branch 1 taken 119 times.
11424 if(--clk2==0)
12225 119 hp-=misc; // store bomb's power in misc
12226 11424 }
12227 else
12228 117616 constant_walk(rate,homing,spw_clipright);
12229
12230 129040 hit_width = (dir<=down) ? 16 : 32;
12231 // hysz = (dir>=left) ? 16 : 32;
12232
12233 129040 return enemy::animate(index);
12234 133094 }
12235
12236 133544 void eDodongo::draw(BITMAP *dest)
12237 {
12238 133544 tile=o_tile;
12239
12240
2/2
✓ Branch 0 taken 3077 times.
✓ Branch 1 taken 130467 times.
133544 if(clk<0)
12241 {
12242 3077 enemy::drawzcboss(dest);
12243 3077 return;
12244 }
12245
12246 130467 update_enemy_frame();
12247 130467 enemy::drawzcboss(dest);
12248
12249
2/2
✓ Branch 0 taken 54026 times.
✓ Branch 1 taken 76441 times.
130467 if(dummy_int[1]!=0) //additional tiles
12250 {
12251 76441 tile+=dummy_int[1]; //second tile is previous tile
12252 76441 xofs-=16; //new xofs change
12253 76441 enemy::drawzcboss(dest);
12254 76441 xofs+=16;
12255 76441 }
12256
12257 133544 }
12258
12259 8681 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12260 {
12261 8681 int32_t wpnId = w->id;
12262 8681 int32_t power = w->power;
12263 8681 int32_t wpnx = w->x;
12264 8681 int32_t wpny = w->y;
12265
12266
5/12
✓ Branch 0 taken 8681 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8681 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2676 times.
✓ Branch 5 taken 6005 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2676 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8681 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12267 6005 return 0;
12268
12269
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 851 times.
✓ Branch 2 taken 1631 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 177 times.
2676 switch(wpnId)
12270 {
12271 case wPhantom:
12272 return 0;
12273
12274 case wFire:
12275 case wBait:
12276 case wWhistle:
12277 case wWind:
12278 case wSSparkle:
12279 case wFSparkle:
12280 return 0;
12281
12282 case wLitBomb:
12283 case wLitSBomb:
12284
6/6
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 564 times.
✓ Branch 2 taken 307 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 732 times.
✓ Branch 5 taken 119 times.
851 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12285 732 return 0;
12286
12287 119 clk2=96;
12288 119 misc=power;
12289
12290
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 3 times.
119 if(wpnId==wLitSBomb)
12291 3 item_set=isSBOMB100;
12292
12293 119 return 1;
12294
12295 case wBomb:
12296 case wSBomb:
12297
6/6
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 1095 times.
✓ Branch 2 taken 463 times.
✓ Branch 3 taken 1168 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 1044 times.
1631 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12298 587 return 0;
12299
12300 1044 stunclk=160;
12301 1044 misc=wpnId; // store wpnId
12302 1044 return 1;
12303
12304 case wSword:
12305
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 92 times.
177 if(stunclk)
12306 {
12307 92 sfx(WAV_EHIT,pan(x));
12308 92 hp=0;
12309 92 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12310 92 fading=0; // don't flash
12311 92 return 1;
12312 }
12313
12314 [[fallthrough]];
12315 default:
12316 102 sfx(WAV_CHINK,pan(x));
12317 102 }
12318
12319 102 return 1;
12320 8681 }
12321
12322 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12323 48 {
12324 48 fading=fade_flash_die;
12325 //nets+5180;
12326 48 previous_dir=-1;
12327
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12328 {
12329 1 dir=up;
12330 1 }
12331
12332
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12333 {
12334 dir=left;
12335 }
12336
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12337 48 }
12338
12339 39398 bool eDodongo2::animate(int32_t index)
12340 {
12341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12342
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12343 {
12344 1158 return Dead(index);
12345 }
12346
12347
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12348 {
12349 167 removearmos(x,y);
12350 167 }
12351
12352
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12353 {
12354
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12355 42 hp-=misc; // store bomb's power in misc
12356 4032 }
12357 else
12358 34208 constant_walk(rate,homing,spw_clipbottomright);
12359
12360 38240 hit_width = (dir<=down) ? 16 : 32;
12361 38240 hit_height = (dir>=left) ? 16 : 32;
12362 38240 hxofs=(dir>=left)?-8:0;
12363 38240 hyofs=(dir<left)?-8:0;
12364
12365 38240 return enemy::animate(index);
12366 39398 }
12367
12368 39601 void eDodongo2::draw(BITMAP *dest)
12369 {
12370
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12371 {
12372 768 enemy::drawzcboss(dest);
12373 768 return;
12374 }
12375
12376 38833 int32_t tempx=xofs;
12377 38833 int32_t tempy=yofs;
12378 38833 update_enemy_frame();
12379 38833 enemy::drawzcboss(dest);
12380 38833 tile+=dummy_int[1]; //second tile change
12381 38833 xofs+=dummy_int[2]; //new xofs change
12382 38833 yofs+=dummy_int[3]; //new yofs change
12383 38833 enemy::drawzcboss(dest);
12384 38833 xofs=tempx;
12385 38833 yofs=tempy;
12386 39601 }
12387
12388 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12389 {
12390 3929 int32_t wpnId = w->id;
12391 3929 int32_t power = w->power;
12392 3929 int32_t wpnx = w->x;
12393 3929 int32_t wpny = w->y;
12394
12395
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12396 2377 return 0;
12397
12398
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12399 {
12400 case wPhantom:
12401 return 0;
12402
12403 case wFire:
12404 case wBait:
12405 case wWhistle:
12406 case wWind:
12407 case wSSparkle:
12408 case wFSparkle:
12409 346 return 0;
12410
12411 case wLitBomb:
12412 case wLitSBomb:
12413
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12414 {
12415 case up:
12416
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12417 77 return 0;
12418
12419 4 break;
12420
12421 case down:
12422
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12423 71 return 0;
12424
12425 6 break;
12426
12427 case left:
12428
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12429 66 return 0;
12430
12431 16 break;
12432
12433 case right:
12434
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12435 65 return 0;
12436
12437 16 break;
12438 }
12439
12440 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12441 // return 0;
12442 42 clk2=96;
12443 42 misc=power;
12444
12445
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12446 item_set=isSBOMB100;
12447
12448 42 return 1;
12449
12450 case wBomb:
12451 case wSBomb:
12452
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12453 {
12454 case up:
12455
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12456 84 return 0;
12457
12458 92 break;
12459
12460 case down:
12461
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12462 113 return 0;
12463
12464 55 break;
12465
12466 case left:
12467
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12468 80 return 0;
12469
12470 105 break;
12471
12472 case right:
12473
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12474 71 return 0;
12475
12476 93 break;
12477 }
12478
12479 345 stunclk=160;
12480 345 misc=wpnId; // store wpnId
12481 345 return 1;
12482
12483 case wSword:
12484
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12485 {
12486 34 sfx(WAV_EHIT,pan(x));
12487 34 hp=0;
12488 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12489 34 fading=0; // don't flash
12490 34 return 1;
12491 }
12492
12493 [[fallthrough]];
12494 default:
12495 158 sfx(WAV_CHINK,pan(x));
12496 158 }
12497
12498 158 return 1;
12499 3929 }
12500
12501 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12502 126 {
12503 //these are here to bypass compiler warnings about unused arguments
12504
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12505 {
12506
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12507 126 }
12508 else { x = X; y = Y; }
12509
12510 //nets+5940;
12511
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12512 {
12513 81 }
12514 else
12515 {
12516
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12517 {
12518 7 flip=1;
12519 7 }
12520 }
12521
12522
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12523 126 clk3=32;
12524 126 clk2=0;
12525 126 clk4=clk;
12526 126 dir=left;
12527
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12528 126 }
12529
12530 71899 bool eAquamentus::animate(int32_t index)
12531 {
12532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12533
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12534 2092 return Dead(index);
12535
12536 // fbx=x+((id==eRAQUAM)?4:-4);
12537
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12538 {
12539 317 removearmos(x,y);
12540 317 }
12541
12542 69807 fbx=x;
12543
12544 /*
12545 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12546 {
12547 fbx+=16;
12548 }
12549 */
12550
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12551 {
12552 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12553 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12554 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12555 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12556 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12557 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12558 450 sfx(wpnsfx(wpn),pan(x));
12559 450 }
12560
12561
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 21018 times.
✓ Branch 3 taken 345 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12562 {
12563 345 clk3=32;
12564 345 }
12565
12566 69807 int screen_x = x.getInt()%256;
12567
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12568 {
12569 1117 int32_t d2=(zc_oldrand()%3)+1;
12570
12571
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12572 {
12573 752 dir=d2;
12574 752 }
12575
12576
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 385 times.
1117 if(dmisc1)
12577 {
12578
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12579 {
12580 38 dir=right;
12581 38 }
12582
12583
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12584 {
12585 dir=left;
12586 }
12587 385 }
12588 else
12589 {
12590
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(screen_x<=136)
12591 {
12592 21 dir=right;
12593 21 }
12594
12595
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(screen_x>=200)
12596 {
12597 34 dir=left;
12598 34 }
12599 }
12600 1117 }
12601
12602
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12603 {
12604
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12605 {
12606 4546 x-=1;
12607 4546 }
12608 else
12609 {
12610 3995 x+=1;
12611 }
12612 8541 }
12613
12614 69807 clk4=(clk4+1)%256;
12615
12616 69807 return enemy::animate(index);
12617 71899 }
12618
12619 72310 void eAquamentus::draw(BITMAP *dest)
12620 {
12621
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12622 {
12623 44994 xofs=(dmisc1?-16:0);
12624
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12625
12626
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12627 {
12628 1312 xofs=0;
12629 1312 enemy::draw(dest);
12630 1312 }
12631 else
12632 {
12633 43682 drawblock(dest,15);
12634 }
12635 44994 }
12636 else
12637 {
12638 27316 int32_t xblockofs=((dmisc1)?-16:16);
12639 27316 xofs=0;
12640
12641
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12642 {
12643 1462 enemy::draw(dest);
12644 1462 return;
12645 }
12646
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12647 {
12648 // face (0=firing, 2=resting)
12649 25854 tile=o_tile+((clk3>0)?0:2);
12650 25854 enemy::draw(dest);
12651 // tail (
12652 25854 tile=o_tile+((clk&16)?1:3);
12653 25854 xofs=xblockofs;
12654 25854 enemy::draw(dest);
12655 // body
12656 25854 yofs+=16;
12657 25854 xofs=0;
12658 25854 tile=o_tile+((clk&16)?20:22);
12659 25854 enemy::draw(dest);
12660 25854 xofs=xblockofs;
12661 25854 tile=o_tile+((clk&16)?21:23);
12662 25854 enemy::draw(dest);
12663 25854 yofs-=16;
12664 25854 }
12665 else enemy::draw(dest);
12666 }
12667 72310 }
12668
12669 23834 bool eAquamentus::hit(weapon *w)
12670 {
12671
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12672
12673
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12674 {
12675 case wBeam:
12676 case wRefBeam:
12677 case wMagic:
12678 4201 hit_height=32;
12679 4201 }
12680
12681
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12682 23834 hit_height=16;
12683 23834 return ret;
12684
12685 23834 }
12686
12687 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12688 93 {
12689
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12690 {
12691
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12692 93 }
12693 else { x = X; y = Y; }
12694
12695 93 Clk=Clk;
12696
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12697 {
12698 clk=0;
12699 superman = 1;
12700 fading=fade_flicker;
12701 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12702 }
12703
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12704 {
12705 42 clk=0;
12706 42 }
12707 93 hxofs=-16;
12708 93 hit_width=48;
12709 93 clk4=0;
12710
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12711
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12712
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12713
12714 //nets+5340;
12715 93 }
12716
12717 70891 bool eGohma::animate(int32_t index)
12718 {
12719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12720
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12721 1226 return Dead(index);
12722
12723
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12724 {
12725
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12726 {
12727 35 clk4=0;
12728 35 superman=0;
12729 35 fading=0;
12730 35 clk=0;
12731
12732 35 }
12733 1 else return enemy::animate(index);
12734 35 }
12735
12736
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12737 {
12738
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
350 if (activated_handle && !activated_handle->is_rpos()) removearmos(x,y);
12739 else
12740 {
12741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12742 350 did_armos = false;
12743 350 removearmos(x,y);
12744 350 did_armos = false;
12745
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12746 }
12747 350 }
12748
12749
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12750
12751 // Movement clk must be separate from animation clk because of the Clock item
12752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12753 68878 clk4++;
12754
12755
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12756 {
12757
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12758 546 dir^=1;
12759 else
12760 486 dir=zc_oldrand()%3+1;
12761 1032 }
12762
12763
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12764 {
12765
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12766 {
12767 case 1:
12768 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12769 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12770 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12771 235 sfx(wpnsfx(wpn),pan(x));
12772 235 break;
12773
12774 default:
12775
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12776 {
12777 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12778 754 sfx(wpnsfx(wpn),pan(x));
12779 754 sfx(wpnsfx(wpn),pan(x));
12780 754 }
12781
12782 882 break;
12783 }
12784 1117 }
12785
12786
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12787 {
12788
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12789 {
12790 290 FireBreath(true);
12791 290 }
12792 2215 }
12793
12794
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12795 34479 move((zfix)1);
12796
12797
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12798 150 clk3=0;
12799
12800 68878 return enemy::animate(index);
12801 70891 }
12802
12803 70889 void eGohma::draw(BITMAP *dest)
12804 {
12805 70889 tile=o_tile;
12806
12807
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12808 {
12809 2012 enemy::drawzcboss(dest);
12810 2012 return;
12811 }
12812
12813
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12814 {
12815 ///if ( do_animation )
12816 //Yuck. Gohma can just not have this capability right now.
12817 // left side
12818 53472 xofs=-16;
12819 53472 flip=0;
12820 // if(clk&16) tile=180;
12821 // else { tile=182; flip=1; }
12822 53472 tile+=(3*((clk&48)>>4));
12823 53472 enemy::drawzcboss(dest);
12824
12825 // right side
12826 53472 xofs=16;
12827 // tile=(180+182)-tile;
12828 53472 tile=o_tile;
12829 53472 tile+=(3*((clk&48)>>4))+2;
12830 53472 enemy::drawzcboss(dest);
12831
12832 // body
12833 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12834 53472 tile=o_tile;
12835
12836 // tile+=(3*((clk&24)>>3))+2;
12837
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12838 2975 tile+=7;
12839
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12840 15890 tile+=10;
12841
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12842 2051 tile+=7;
12843 else
12844 32556 tile+=((clk3-132)&24)?4:1;
12845
12846 53472 enemy::drawzcboss(dest);
12847
12848 53472 }
12849 else
12850 {
12851 // left side
12852 15405 xofs=-16;
12853 15405 flip=0;
12854
12855
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12856 {
12857 7790 tile+=2;
12858 7790 flip=1;
12859 7790 }
12860
12861 15405 enemy::draw(dest);
12862
12863 // right side
12864 15405 tile=o_tile;
12865 15405 xofs=16;
12866
12867
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12868
12869 // tile=(180+182)-tile;
12870 15405 enemy::draw(dest);
12871
12872 // body
12873 15405 tile=o_tile;
12874 15405 xofs=0;
12875
12876
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12877 912 tile+=4;
12878
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12879 4882 tile+=5;
12880
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12881 585 tile+=4;
12882 9026 else tile+=((clk3-132)&8)?3:1;
12883
12884 15405 enemy::draw(dest);
12885
12886 }
12887 70889 }
12888
12889 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12890 {
12891 578 int32_t wpnId = w->id;
12892 578 int32_t power = w->power;
12893 578 int32_t wpnx = w->x;
12894 578 int32_t wpnDir = w->dir;
12895 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12896
12897
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12898 {
12899
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12900 {
12901 93 sfx(WAV_CHINK,pan(x));
12902 93 return 1;
12903 }
12904 328 }
12905
12906 485 return enemy::takehit(w, realweap);
12907 578 }
12908
12909 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12910 327 {
12911 327 count_enemy=(id==(id&0xFFF));
12912 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
12913
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
12914 327 }
12915
12916 124050 bool eLilDig::animate(int32_t index)
12917 {
12918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
12919
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
12920 4410 return Dead(index);
12921
12922
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
12923 {
12924 7105 removearmos(x,y);
12925 7105 }
12926
12927
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
12928 {
12929
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
12930 1161 step+=0.25;
12931 38646 }
12932
12933 119640 variable_walk_8(rate,homing,hrate,spw_floater);
12934 119640 return enemy::animate(index);
12935 124050 }
12936
12937 124268 void eLilDig::draw(BITMAP *dest)
12938 {
12939 124268 tile = o_tile;
12940 // tile = 160;
12941 124268 int32_t fdiv = frate/4;
12942
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
12943
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
12944 124268 efrate:((clk>=(frate>>1))?1:0);
12945
12946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
12947 {
12948
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
12949 {
12950
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
12951 {
12952 case up: //u
12953 11370 flip=0;
12954 11370 break;
12955
12956 case l_up: //d
12957 10699 flip=0;
12958 10699 tile+=4;
12959 10699 break;
12960
12961 case l_down: //l
12962 10722 flip=0;
12963 10722 tile+=8;
12964 10722 break;
12965
12966 case left: //r
12967 12015 flip=0;
12968 12015 tile+=12;
12969 12015 break;
12970
12971 case r_down: //ul
12972 10070 flip=0;
12973 10070 tile+=20;
12974 10070 break;
12975
12976 case down: //ur
12977 9554 flip=0;
12978 9554 tile+=24;
12979 9554 break;
12980
12981 case r_up: //dl
12982 8255 flip=0;
12983 8255 tile+=28;
12984 8255 break;
12985
12986 case right: //dr
12987 10033 flip=0;
12988 10033 tile+=32;
12989 10033 break;
12990 }
12991
12992 91457 tile+=f2;
12993 91457 }
12994 else
12995 {
12996 32811 tile+=(clk>=6)?1:0;
12997 }
12998 124268 }
12999
13000 124268 enemy::draw(dest);
13001 124268 }
13002
13003 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13004 80 {
13005
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13006 80 }
13007
13008 29662 bool eBigDig::animate(int32_t index)
13009 {
13010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13012 return Dead(index);
13013
13014
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13015 {
13016 4104 removearmos(x,y);
13017 4104 }
13018
13019
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13020 {
13021 case 0:
13022 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13023 29534 break;
13024
13025 case 1:
13026 64 ++misc;
13027 64 break;
13028
13029 case 2:
13030
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64 if (!get_qr(qr_NO_DEATH_EVENTS_FOR_SEGMENTED_ENEMY_CORES) && !death_event())
13031 {
13032 // saved by script
13033 misc = 0;
13034 break;
13035 }
13036
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13037 {
13038 111 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13039 111 }
13040
13041
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13042 {
13043 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13044 30 }
13045
13046
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13047 {
13048 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13049 30 }
13050
13051
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13052 {
13053 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13054 30 }
13055
13056
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13057 {
13058 2 int guycarryingitem = guys.Count()-1;
13059 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13060 2 itemguy = false;
13061 2 }
13062
13063 64 stop_bgsfx(index);
13064
13065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(x));
13066
13067 64 return true;
13068 }
13069
13070 29598 return enemy::animate(index);
13071 29662 }
13072
13073 29658 void eBigDig::draw(BITMAP *dest)
13074 {
13075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13076 {
13077 update_enemy_frame();
13078 xofs-=8;
13079 yofs-=8;
13080 drawblock(dest,15);
13081 xofs+=8;
13082 yofs+=8;
13083 return;
13084 }
13085
13086 29658 tile = o_tile;
13087 29658 int32_t fdiv = frate/4;
13088
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13089
13090
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13091 29658 efrate:((clk>=(frate>>1))?1:0);
13092
13093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13094 {
13095
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13096 {
13097
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13098 {
13099 case up: //u
13100 1688 flip=0;
13101 1688 break;
13102
13103 case l_up: //d
13104 1684 flip=0;
13105 1684 tile+=8;
13106 1684 break;
13107
13108 case l_down: //l
13109 2031 flip=0;
13110 2031 tile+=40;
13111 2031 break;
13112
13113 case left: //r
13114 1910 flip=0;
13115 1910 tile+=48;
13116 1910 break;
13117
13118 case r_down: //ul
13119 2041 flip=0;
13120 2041 tile+=80;
13121 2041 break;
13122
13123 case down: //ur
13124 2043 flip=0;
13125 2043 tile+=88;
13126
13127 2043 break;
13128
13129 case r_up: //dl
13130 1514 flip=0;
13131 1514 tile+=120;
13132 1514 break;
13133
13134 case right: //dr
13135 2241 flip=0;
13136 2241 tile+=128;
13137 2241 break;
13138 }
13139
13140 16161 tile+=(f2*2);
13141 16161 }
13142 else
13143 {
13144 13497 tile+=(f2)?0:2;
13145 13497 flip=(clk&1)?1:0;
13146 }
13147 29658 }
13148
13149 29658 xofs-=8;
13150 29658 yofs-=8;
13151 29658 drawblock(dest,15);
13152 29658 xofs+=8;
13153 29658 yofs+=8;
13154 29658 }
13155
13156 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13157 {
13158 869 int32_t wpnId = w->id;
13159
13160
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13161 {
13162 64 misc = 1;
13163 64 w->hit_pierce(this, 0, false);
13164 64 }
13165
13166 869 return 0;
13167 }
13168
13169 80 void eBigDig::init_size_flags()
13170 {
13171 80 SIZEflags = d->SIZEflags;
13172
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13173 // al_trace("Enemy txsz:%i\n", txsz);
13174
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13175
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13176 80 else hit_width = 32;
13177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13178 80 else hit_height = 32;
13179
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13180 80 else hzsz = 16; // hard to jump.
13181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13182 80 else hxofs = -8;
13183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13184 80 else hyofs = -8;
13185 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13186
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13187
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13188 {
13189 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13190 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13191 }
13192
13193
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13194 80 }
13195
13196 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13197 13 {
13198 13 hxofs=hyofs=8;
13199
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13200 {
13201 hxofs = 4;
13202 hyofs = 4;
13203 hit_width = 24;
13204 hit_height = 24;
13205 SIZEflags|=OVERRIDE_HIT_WIDTH;
13206 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13207 }
13208 13 hzsz=16; //can't be jumped.
13209 13 clk2=70;
13210 13 misc=-1;
13211
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 mapscr* scr = get_scr(screen_spawned);
13212
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13213 13 }
13214
13215 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13216 {
13217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13218
13219 return Dead(index);
13220
13221
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13222 {
13223 72 removearmos(x,y);
13224 72 }
13225
13226
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13227 {
13228 case -1:
13229 13 misc=0;
13230 [[fallthrough]];
13231 case 0:
13232
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13233 {
13234 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13235 173 sfx(wpnsfx(wpn),pan(x));
13236 173 clk2=0;
13237 173 }
13238
13239 12693 Stunclk=0;
13240 12693 constant_walk(rate,homing,spw_none);
13241 12693 break;
13242
13243 case 1:
13244 case 2:
13245
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13246 {
13247 41 int32_t r=zc_oldrand();
13248
13249
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13250 {
13251 17 y=96;
13252
13253
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13254 6 x=160;
13255 else
13256 11 x=48;
13257
13258
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13259 8 x=208-x;
13260
13261 17 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13262 17 }
13263
13264 41 loadpalset(csBOSS,pSprite(d->bosspal));
13265 41 misc=0;
13266 41 }
13267
13268 3607 break;
13269
13270 case 3:
13271 {
13272
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13273 972 break;
13274
13275 12 misc=4;
13276 12 clk=0;
13277 12 hxofs=1000;
13278 12 loadpalset(9,pSprite(spPILE));
13279 12 music_stop();
13280 12 stop_sfx(WAV_ROAR);
13281
13282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(x));
13283
13284 12 sfx(WAV_GANON);
13285 //Ganon's dustpile; fall in sideview. -Z
13286 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13287 //dustpile->miscellaneous[31] = eeGANON;
13288
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13289 12 item *dustpile = NULL;
13290 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13291 12 dustpile = (item *)items.spr(items.Count() - 1);
13292 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13293 12 break;
13294 }
13295
13296 case 4:
13297
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13298 {
13299 12 misc=5;
13300
13301 //game->lvlitems[dlevel]|=(1 << li_boss_killed);
13302
13303 12 sfx(WAV_CLEARED);
13304 //Add the big TF over the ashes!
13305
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13306 {
13307 24 item *ashes = (item*)items.spr(q);
13308
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13309 {
13310 //Z_scripterrlog("Found correct dustpile!\n");
13311
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13312 12 item *bigtriforce = NULL;
13313 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13314 12 bigtriforce->linked_parent = eeGANON;
13315 12 }
13316 24 }
13317 12 }
13318
13319 960 break;
13320 10 case 5: return true;
13321 }
13322
13323 18244 return enemy::animate(index);
13324 18254 }
13325
13326
13327 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13328 {
13329 //these are here to bypass compiler warnings about unused arguments
13330 964 int32_t wpnId = w->id;
13331 964 int32_t power = w->power;
13332 964 int32_t enemyHitWeapon = w->parentitem;
13333
13334
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13335 {
13336 case 0:
13337
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13338 31 return 0;
13339
13340 53 hp-=power;
13341
13342
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13343 {
13344 41 misc=1;
13345 41 Stunclk=64;
13346 41 }
13347 else
13348 {
13349 12 loadpalset(csBOSS,pSprite(spBROWN));
13350 12 misc=2;
13351 12 Stunclk=284;
13352 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13353 }
13354
13355 53 sfx(WAV_EHIT,pan(x));
13356
13357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(x));
13358
13359 53 return 1;
13360
13361 case 2:
13362
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13363 154 return 0;
13364
13365 12 misc=3;
13366 12 hclk=81;
13367 12 loadpalset(9,pSprite(spBROWN));
13368 12 return 1;
13369 }
13370
13371 714 return 0;
13372 964 }
13373
13374 20776 void eGanon::draw(BITMAP *dest)
13375 {
13376
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13377 {
13378 case 0:
13379
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13380 3169 tile=(zc_oldrand()%5)*2+o_tile;
13381
13382
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13383 {
13384
13385 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13386 {
13387 int odraw = drawstyle;
13388 drawstyle = 2;
13389 drawblock(dest,15);
13390 drawstyle = odraw;
13391 }
13392 else
13393 {
13394 drawblock(dest,15);
13395 }
13396 break;
13397
13398 }
13399
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13400 {
13401 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13402 {
13403 int odraw = drawstyle;
13404 drawstyle = 2;
13405 drawblock(dest,15);
13406 drawstyle = odraw;
13407 }
13408 else
13409 {
13410 drawblock(dest,15);
13411 }
13412 break;
13413 }
13414
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13415 12680 break;
13416 [[fallthrough]];
13417 case 2:
13418
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13419 break;
13420 [[fallthrough]];
13421 case -1:
13422 3518 tile=o_tile;
13423
13424 [[fallthrough]];
13425 case 1:
13426 case 3:
13427 7126 drawblock(dest,15);
13428 7126 break;
13429
13430 case 4:
13431 960 draw_guts(dest);
13432 960 draw_flash(dest);
13433 960 break;
13434 }
13435 20776 }
13436
13437 960 void eGanon::draw_guts(BITMAP *dest)
13438 {
13439
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13440 960 tile = clk<24 ? 74 : 75;
13441 960 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13442 960 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13443 960 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13444 960 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13445 960 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13446 960 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13447 960 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13448 960 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13449 960 }
13450
13451 960 void eGanon::draw_flash(BITMAP *dest)
13452 {
13453
13454 960 int32_t c = clk-(clk>>2);
13455 960 cs = (frame&3)+6;
13456 960 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13457 960 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13458 960 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13459 960 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13460 960 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13461 960 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13462 960 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13463 960 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13464 960 }
13465
13466 19 void getBigTri(mapscr* scr, int32_t id2)
13467 {
13468 /*
13469 *************************
13470 * BIG TRIFORCE SEQUENCE *
13471 *************************
13472 0 BIGTRI out, WHITE flash in
13473 4 WHITE flash out, PILE cset white
13474 8 WHITE in
13475 ...
13476 188 WHITE out
13477 191 PILE cset red
13478 200 top SHUTTER opens
13479 209 bottom SHUTTER opens
13480 */
13481 19 sfx(itemsbuf[id2].playsound);
13482 19 guys.clear();
13483
13484
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15 times.
19 if(itemsbuf[id2].flags & item_gamedata)
13485 {
13486 4 game->lvlitems[dlevel]|=(1 << li_mcguffin);
13487 4 }
13488
13489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13490
13491 19 draw_screen();
13492
13493
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 3648 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 3648 times.
3667 for(int32_t f=0; f<24*8 && !Quit; f++)
13494 {
13495
2/2
✓ Branch 0 taken 3629 times.
✓ Branch 1 taken 19 times.
3648 if(f==4)
13496 {
13497
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 19 times.
304 for(int32_t i=1; i<16; i++)
13498 {
13499 285 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13500 285 }
13501 19 }
13502
13503
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 456 times.
3648 if((f&7)==0)
13504 {
13505
2/2
✓ Branch 0 taken 1368 times.
✓ Branch 1 taken 456 times.
1824 for(int32_t cs=2; cs<5; cs++)
13506 {
13507
2/2
✓ Branch 0 taken 20520 times.
✓ Branch 1 taken 1368 times.
21888 for(int32_t i=1; i<16; i++)
13508 {
13509 20520 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13510 20520 }
13511 1368 }
13512
13513 456 refreshpal=true;
13514 456 }
13515
13516
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 456 times.
3648 if((f&7)==4)
13517 {
13518
1/2
✓ Branch 0 taken 456 times.
✗ Branch 1 not taken.
456 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13519 else loadlvlpal(0xB);
13520 456 }
13521
13522
2/2
✓ Branch 0 taken 3629 times.
✓ Branch 1 taken 19 times.
3648 if(f==191)
13523 {
13524 19 loadpalset(9,pSprite(spPILE));
13525 19 }
13526
13527 3648 advanceframe(true);
13528 3648 }
13529
13530 //play_DmapMusic();
13531 19 playLevelMusic();
13532
13533
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
19 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13534 {
13535 6 Hero.dowarp(hero_scr, 1, 0); //side warp
13536 6 }
13537 19 }
13538
13539 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13540 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13541 618 {
13542
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13543 {
13544
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 position_relative_to_screen(x, y, 128, 48);
13545 618 }
13546 //else { x = X; y = Y; }
13547
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13548 618 superman=1;
13549 618 fading=fade_invisible;
13550 618 hxofs=1000;
13551 618 segcnt=clk;
13552 618 segid=Id|0x1000;
13553 618 clk=0;
13554
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13555
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13556 618 tile=o_tile;
13557 618 hitdir = -1;
13558 618 stickclk = 0;
13559
13560 /*
13561 if (get_qr(qr_NEWENEMYTILES))
13562 {
13563 tile=nets+1220;
13564 }
13565 else
13566 {
13567 tile=57;
13568 }
13569 */
13570 618 }
13571
13572 244844 bool eMoldorm::animate(int32_t index)
13573 {
13574 244844 update_current_screen();
13575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13576 244844 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13577
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13578 {
13579 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13580 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13581 28475 }
13582
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13583 {
13584 562 stickclk = 0;
13585 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13586 562 }
13587
13588
13589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13590 {
13591 244844 removearmos(x,y);
13592 244844 }
13593
13594
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13595 {
13596
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13597 {
13598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13599 129 never_return(screen_spawned, index);
13600
13601
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13602 129 leave_item();
13603
13604 129 stop_bgsfx(index);
13605
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (!get_qr(qr_NO_DEATH_EVENTS_FOR_SEGMENTED_ENEMY_CORES))
13606 death_event(); // can't cancel core death of segmented enemy
13607 129 return true;
13608 }
13609 2322 }
13610 else
13611 {
13612
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13613 stunclk=0;
13614 242393 constant_walk_8_old(rate,homing,spw_floater);
13615
13616
13617 242393 misc=dir;
13618
13619 // If any higher-numbered segments were killed, segcnt can be too high,
13620 // leading to a crash
13621
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13622 segcnt=guys.Count()-index-1;
13623
13624
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
13625 {
13626 1122281 enemy* segment=((enemy*)guys.spr(i));
13627
13628 // More validation - if segcnt was wrong, this may not
13629 // actually be a Moldorm segment
13630
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
13631 {
13632 segcnt=i-index-1;
13633 break;
13634 }
13635
13636
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
13637 {
13638 242669 x=segment->x;
13639 242669 y=segment->y;
13640 242669 }
13641
13642 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13643 //Script your own blasted segmented bosses!! -Z
13644 1122281 segment->setParent(this);
13645
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
13646 {
13647 217733 segment->dummy_int[1]=2;
13648 217733 }
13649 else
13650 {
13651 904548 segment->dummy_int[1]=1;
13652 }
13653
13654
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
13655 {
13656 242669 segment->dummy_int[1]=0;
13657 242669 }
13658
13659
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
13660 {
13661 1016 int32_t offset=1;
13662
13663
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
13664 {
13665 // Triple-check
13666
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
13667 {
13668 segcnt=j-index+1; // Add 1 because of --segcnt below
13669 break;
13670 }
13671 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13672 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13673 1480 }
13674
13675 1016 segment->hclk=33;
13676 1016 --segcnt;
13677 1016 --i; // Recheck the same index in case multiple segments died at once
13678 1016 }
13679 1122281 }
13680
13681
2/2
✓ Branch 0 taken 242264 times.
✓ Branch 1 taken 129 times.
242393 if(segcnt==0)
13682 {
13683 129 clk2=19;
13684
13685 129 x=guys.spr(index+1)->x;
13686 129 y=guys.spr(index+1)->y;
13687 129 }
13688 }
13689
13690 244715 return false;
13691 244844 }
13692
13693 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13694 3150 {
13695
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
13696 {
13697
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 position_relative_to_screen(x, y, 128, 48);
13698 3150 }
13699
13700
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13701 3150 hyofs=4;
13702 3150 hit_width=hit_height=8;
13703 3150 hxofs=1000;
13704 3150 mainguy=count_enemy=false;
13705 3150 parentclk = 0;
13706 3150 bgsfx=-1;
13707
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
13708 //deadsfx = WAV_EDEAD;
13709 3150 isCore = false;
13710 3150 }
13711
13712 1138024 bool esMoldorm::animate(int32_t index)
13713 {
13714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
13715 // Shouldn't be possible, but better to be sure
13716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
13717 dying=true;
13718
13719
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
13720 {
13721
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
13722 15743 item_set=0;
13723
13724 15743 return Dead(index);
13725 }
13726
13727
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
13728 {
13729 1017204 hxofs=4;
13730 1017204 step=((enemy*)guys.spr(index-1))->step;
13731
13732
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
13733 {
13734 70455 misc=dir;
13735 70455 dir=((enemy*)guys.spr(index-1))->misc;
13736 //do alignment, as in parent's animation :-/ -DD
13737 70455 x.doFloor();
13738 70455 y.doFloor();
13739 70455 }
13740
13741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
13742 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13743
13744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
13745 {
13746 1017204 sprite::move(step);
13747 1017204 }
13748 1017204 }
13749
13750 1122281 return enemy::animate(index);
13751 1138024 }
13752
13753 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13754 {
13755
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
13756 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13757
13758 453 return 0;
13759 2683 }
13760
13761 1155313 void esMoldorm::draw(BITMAP *dest)
13762 {
13763 1155313 tile=o_tile;
13764 1155313 int32_t fdiv = frate/4;
13765
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13766
13767
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13768 1155313 efrate:((clk>=(frate>>1))?1:0);
13769
13770
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
13771 {
13772 1043930 tile+=dummy_int[1]*40;
13773
13774
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13775 {
13776 102730 flip=0;
13777
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13778
13779
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13780 tile+=4;
13781 102730 }
13782 else
13783 {
13784
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13785 {
13786 case up: //u
13787 96530 flip=0;
13788 96530 break;
13789
13790 case l_up: //d
13791 134534 flip=0;
13792 134534 tile+=4;
13793 134534 break;
13794
13795 case l_down: //l
13796 113426 flip=0;
13797 113426 tile+=8;
13798 113426 break;
13799
13800 case left: //r
13801 124800 flip=0;
13802 124800 tile+=12;
13803 124800 break;
13804
13805 case r_down: //ul
13806 101314 flip=0;
13807 101314 tile+=20;
13808 101314 break;
13809
13810 case down: //ur
13811 99043 flip=0;
13812 99043 tile+=24;
13813 99043 break;
13814
13815 case r_up: //dl
13816 131794 flip=0;
13817 131794 tile+=28;
13818 131794 break;
13819
13820 case right: //dr
13821 139759 flip=0;
13822 139759 tile+=32;
13823 139759 break;
13824 }
13825 }
13826
13827 1043930 tile+=f2;
13828 1043930 }
13829
13830
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
13831 1049046 enemy::draw(dest);
13832 1155313 }
13833
13834 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13835 420 {
13836
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
13837 {
13838
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 position_relative_to_screen(x, y, 64, 80);
13839 420 }
13840 //else { x = X; y = Y; }
13841 //byte legaldirs = 0;
13842 420 int32_t incr = 16;
13843 //int32_t possiiblepos = 0;
13844 //int32_t positions[8] = {0};
13845
13846 //Don't spawn in pits.
13847
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
13848 {
13849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13850 {
13851 //move if we spawn over a pit
13852 //check each direction
13853
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13854 {
13855
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13856 }
13857
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13858 {
13859
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13860 }
13861
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13862 {
13863
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13864 }
13865
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13866 {
13867
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13868 }
13869
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13870 {
13871 y -= incr; break;
13872 }
13873
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13874 {
13875 y+=incr; break;
13876 }
13877
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13878 {
13879
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13880 }
13881
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
13882 {
13883 x+=incr; y+=incr; break;
13884 }
13885 34 else continue;
13886
13887 }
13888
13889 105 }
13890
13891 420 dir=up;
13892 420 superman=1;
13893 420 fading=fade_invisible;
13894 420 hxofs=1000;
13895 420 segcnt=clk;
13896 420 clk=0;
13897 //set up move history
13898
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
13899
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
13900 420 }
13901
13902 236907 bool eLanmola::animate(int32_t index)
13903 {
13904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
13905
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
13906 {
13907 40196 removearmos(x,y);
13908 40196 }
13909
13910
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
13911 {
13912
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
13913 {
13914
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
13915 86 leave_item();
13916
13917 189 stop_bgsfx(index);
13918
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if (!get_qr(qr_NO_DEATH_EVENTS_FOR_SEGMENTED_ENEMY_CORES))
13919 death_event(); // can't cancel core death of segmented enemy
13920 189 return true;
13921 }
13922
13923 3402 return false;
13924 }
13925
13926
13927 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
13928 //the direction AND x,y position of the lanmola to vary in uncertain ways.
13929 //I've added a complete movement history to this enemy to compensate -DD
13930 233316 constant_walk(rate,homing,spw_none);
13931 233316 prevState.pop_front();
13932 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
13933
13934 // This could cause a crash with Moldorms. I didn't see the same problem
13935 // with Lanmolas, but it looks like it ought to be possible, so here's
13936 // the same solution. - Saf
13937
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
13938 segcnt=guys.Count()-index-1;
13939
13940
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
13941 {
13942 966396 enemy* segment=((enemy*)guys.spr(i));
13943
13944 // More validation in case segcnt is wrong
13945
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
13946 {
13947 segcnt=i-index-1;
13948 break;
13949 }
13950
13951 966396 segment->o_tile=o_tile;
13952 966396 segment->setParent(this);
13953
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
13954 {
13955 195700 segment->dummy_int[1]=1; //tail
13956 195700 }
13957 else
13958 {
13959 770696 segment->dummy_int[1]=0;
13960 }
13961
13962
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
13963 {
13964
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
13965 {
13966 // Triple-check
13967
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
13968 {
13969 segcnt=j-index+1; // Add 1 because of --segcnt below
13970 break;
13971 }
13972 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13973 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13974 1961 }
13975
13976 1169 ((enemy*)guys.spr(i))->hclk=33;
13977 1169 --segcnt;
13978 1169 --i; // Recheck the same index in case multiple segments died at once
13979 1169 }
13980 966396 }
13981
13982
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
13983 {
13984 189 clk2=19;
13985 189 x=guys.spr(index+1)->x;
13986 189 y=guys.spr(index+1)->y;
13987 189 setmapflag(get_scr(screen_spawned), mTMPNORET);
13988 189 }
13989
13990 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
13991 //which is... disastrous.
13992 233316 hp = 1;
13993 233316 return enemy::animate(index);
13994 236907 }
13995
13996 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13997 2267 {
13998
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
13999 {
14000
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 position_relative_to_screen(x, y, 64, 80);
14001 2267 }
14002 2267 int32_t incr = 16;
14003 //Don't spawn in pits.
14004
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14005 {
14006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14007 {
14008 //move if we spawn over a pit
14009 //check each direction
14010
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14011 {
14012
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14013 }
14014
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14015 {
14016
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14017 }
14018
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14019 {
14020
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14021 }
14022
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14023 {
14024
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14025 }
14026
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14027 {
14028 y -= incr; break;
14029 }
14030
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14031 {
14032 y+=incr; break;
14033 }
14034
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14035 {
14036
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14037 }
14038
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14039 {
14040 x+=incr; y+=incr; break;
14041 }
14042 170 else continue;
14043
14044 }
14045
14046 525 }
14047
14048 2267 hxofs=1000;
14049 2267 hit_width=8;
14050 2267 mainguy=false;
14051 2267 count_enemy=(id<0x2000)?true:false;
14052
14053 //set up move history
14054
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14055
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14056
14057 2267 bgsfx = -1;
14058 2267 isCore = false;
14059
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14060 2267 }
14061
14062 985563 bool esLanmola::animate(int32_t index)
14063 {
14064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14065 // Shouldn't be possible, but who knows
14066
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14067 18 dying=true;
14068
14069
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14070 {
14071 19167 xofs=0;
14072
14073
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14074 9306 item_set=0;
14075
14076 19167 return Dead(index);
14077 }
14078
14079
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14080 {
14081 930450 hxofs=4;
14082
14083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14084 {
14085 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14086 930450 prevState.pop_front();
14087 930450 prevState.push_back(newstate);
14088 930450 x = newstate.first.first;
14089 930450 y = newstate.first.second;
14090 930450 dir = newstate.second;
14091 930450 }
14092 930450 }
14093
14094 966396 return enemy::animate(index);
14095 985563 }
14096
14097 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14098 {
14099
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14100 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14101
14102 590 return 0;
14103 2655 }
14104
14105 990931 void esLanmola::draw(BITMAP *dest)
14106 {
14107 990931 tile=o_tile;
14108 990931 int32_t fdiv = frate/4;
14109
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14110
14111
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14112 990931 efrate:((clk>=(frate>>1))?1:0);
14113
14114
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14115 {
14116
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14117 {
14118 481767 tile+=20;
14119
14120
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14121 {
14122 128742 tile+=20;
14123 128742 }
14124 481767 }
14125
14126
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14127 {
14128 case up:
14129 141419 flip=0;
14130 141419 break;
14131
14132 case down:
14133 140994 flip=0;
14134 140994 tile+=4;
14135 140994 break;
14136
14137 case left:
14138 159500 flip=0;
14139 159500 tile+=8;
14140 159500 break;
14141
14142 case right:
14143 187019 flip=0;
14144 187019 tile+=12;
14145 187019 break;
14146 }
14147
14148 628932 tile+=f2;
14149 628932 }
14150 else
14151 {
14152
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14153 {
14154 271456 tile+=1;
14155 271456 }
14156 }
14157
14158
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14159 953893 enemy::draw(dest);
14160 990931 }
14161
14162 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14163 150 {
14164 //these are here to bypass compiler warnings about unused arguments
14165 150 Clk=Clk;
14166 150 superman=1;
14167
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14168 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14169
14170
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14171 692 arm[i]=i;
14172
14173 150 fading=fade_blue_poof;
14174 //nets+4680;
14175 150 adjusted=false;
14176
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14177 150 }
14178
14179 66494 bool eManhandla::animate(int32_t index)
14180 {
14181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14182
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14183 1382 return Dead(index);
14184
14185
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14186 {
14187 2471 removearmos(x,y);
14188 2471 }
14189
14190
14191 // check arm status, move dead ones to end of group
14192
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14193 {
14194 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14195
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14196 {
14197
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14198 {
14199 552 zc_swap(arm[j],arm[j+1]);
14200 552 guys.swap(index+j+1,index+j+2);
14201 552 }
14202
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14203 {
14204 87 leave_item();
14205 87 }
14206 424 --armcnt;
14207 424 --i;
14208 424 continue;
14209 }
14210
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14211 {
14212
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14213 {
14214 508 cur_arm->o_tile=o_tile+40;
14215 508 cur_arm->setParent(this);
14216 508 }
14217 else
14218 {
14219 184 cur_arm->o_tile=o_tile+160;
14220 184 cur_arm->setParent(this);
14221 }
14222 692 }
14223 193194 }
14224
14225 65112 adjusted=true;
14226
14227 // move or die
14228
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14229 83 hp=0;
14230 else
14231 {
14232 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14233
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14234
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14235 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14236
14237
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14238 {
14239
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14240 {
14241
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14242 {
14243 case 0:
14244 38579 dy1=-24;
14245 38579 break;
14246
14247 case 1:
14248 36328 dy2=31;
14249 36328 break;
14250
14251 case 2:
14252 36250 dx1=-16;
14253 36250 break;
14254
14255 case 3:
14256 39862 dx2=31;
14257 39862 break;
14258 }
14259 151019 }
14260 53584 }
14261 else
14262 {
14263 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14264
14265
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14266 {
14267
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14268 {
14269 case 0:
14270 12012 dy1=-32;
14271 12012 break;
14272
14273 case 1:
14274 7730 dy2=39;
14275 7730 break;
14276
14277 case 2:
14278 9837 dx1=-24;
14279 9837 break;
14280
14281 case 3:
14282 12596 dx2=39;
14283 12596 break;
14284 }
14285 42175 }
14286 }
14287
14288 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14289
14290
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14291 {
14292 193194 zfix dx=(zfix)0,dy=(zfix)0;
14293
14294
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14295 {
14296
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14297 {
14298 case 0:
14299 38579 dy=-16;
14300 38579 break;
14301
14302 case 1:
14303 36328 dy=16;
14304 36328 break;
14305
14306 case 2:
14307 36250 dx=-16;
14308 36250 break;
14309
14310 case 3:
14311 39862 dx=16;
14312 39862 break;
14313 }
14314 151019 }
14315 else
14316 {
14317
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14318 {
14319 case 0:
14320 5447 dy=-24;
14321 5447 dx=-8;
14322 5447 break;
14323
14324 case 1:
14325 3986 dy=24;
14326 3986 dx=8;
14327 3986 break;
14328
14329 case 2:
14330 4163 dx=-24;
14331 4163 dy=8;
14332 4163 break;
14333
14334 case 3:
14335 6774 dx=24;
14336 6774 dy=-8;
14337 6774 break;
14338
14339 case 4:
14340 6565 dy=-24;
14341 6565 dx=8;
14342 6565 break;
14343
14344 case 5:
14345 3744 dy=24;
14346 3744 dx=-8;
14347 3744 break;
14348
14349 case 6:
14350 5674 dx=-24;
14351 5674 dy=-8;
14352 5674 break;
14353
14354 case 7:
14355 5822 dx=24;
14356 5822 dy=8;
14357 5822 break;
14358 }
14359 }
14360
14361 193194 guys.spr(index+i+1)->x = x+dx;
14362 193194 guys.spr(index+i+1)->y = y+dy;
14363 193194 }
14364 }
14365
14366 65112 return enemy::animate(index);
14367 66494 }
14368
14369
14370 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14371 {
14372 1751 int32_t wpnId = w->id;
14373
14374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14375 return 0;
14376
14377
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14378 {
14379 case wBomb:
14380 case wSBomb:
14381 case wSword:
14382 case wHammer:
14383 case wWand:
14384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14385
14386 case wLitBomb:
14387 case wLitSBomb:
14388 case wBait:
14389 case wWhistle:
14390 case wFire:
14391 case wWind:
14392 case wSSparkle:
14393 case wFSparkle:
14394 case wPhantom:
14395 1709 return 0;
14396
14397 case wHookshot:
14398 case wBrang:
14399 sfx(WAV_CHINK,pan(x));
14400 break;
14401
14402 default:
14403
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14404 else sfx(WAV_CHINK,pan(x));
14405
14406 42 }
14407
14408 42 return 1;
14409 1751 }
14410
14411 66490 void eManhandla::draw(BITMAP *dest)
14412 {
14413 66490 tile=o_tile;
14414 66490 int32_t fdiv = frate/4;
14415
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14416
14417
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14418 66490 efrate:((clk>=(frate>>1))?1:0);
14419
14420
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14421 {
14422
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14423 {
14424
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14425 {
14426 case up: //u
14427 4771 flip=0;
14428 4771 break;
14429
14430 case l_up: //d
14431 4640 flip=0;
14432 4640 tile+=4;
14433 4640 break;
14434
14435 case l_down: //l
14436 4995 flip=0;
14437 4995 tile+=8;
14438 4995 break;
14439
14440 case left: //r
14441 5574 flip=0;
14442 5574 tile+=12;
14443 5574 break;
14444
14445 case r_down: //ul
14446 3793 flip=0;
14447 3793 tile+=20;
14448 3793 break;
14449
14450 case down: //ur
14451 3930 flip=0;
14452 3930 tile+=24;
14453 3930 break;
14454
14455 case r_up: //dl
14456 3908 flip=0;
14457 3908 tile+=28;
14458 3908 break;
14459
14460 case right: //dr
14461 5883 flip=0;
14462 5883 tile+=32;
14463 5883 break;
14464 }
14465
14466 37494 tile+=f2;
14467 37494 enemy::draw(dest);
14468 37494 } //manhandla 2, big body
14469 else
14470 {
14471
14472
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14473 {
14474 case up: //u
14475 1277 flip=0;
14476 1277 break;
14477
14478 case l_up: //d
14479 1360 flip=0;
14480 1360 tile+=8;
14481 1360 break;
14482
14483 case l_down: //l
14484 2242 flip=0;
14485 2242 tile+=40;
14486 2242 break;
14487
14488 case left: //r
14489 1789 flip=0;
14490 1789 tile+=48;
14491 1789 break;
14492
14493 case r_down: //ul
14494 1345 flip=0;
14495 1345 tile+=80;
14496 1345 break;
14497
14498 case down: //ur
14499 805 flip=0;
14500 805 tile+=88;
14501 805 break;
14502
14503 case r_up: //dl
14504 948 flip=0;
14505 948 tile+=120;
14506 948 break;
14507
14508 case right: //dr
14509 1542 flip=0;
14510 1542 tile+=128;
14511 1542 break;
14512 }
14513
14514 11308 tile+=(f2*2);
14515 11308 xofs-=8;
14516 11308 yofs-=8;
14517 11308 drawblock(dest,15);
14518 11308 xofs+=8;
14519 11308 yofs+=8;
14520 }
14521 48802 }
14522 else
14523 {
14524
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14525 {
14526 17173 enemy::draw(dest);
14527 17173 }
14528 else
14529 {
14530 515 xofs-=8;
14531 515 yofs-=8;
14532 515 enemy::draw(dest);
14533 515 xofs+=16;
14534 515 enemy::draw(dest);
14535 515 yofs+=16;
14536 515 enemy::draw(dest);
14537 515 xofs-=16;
14538 515 enemy::draw(dest);
14539 515 xofs+=8;
14540 515 yofs-=8;
14541 }
14542 }
14543 66490 }
14544
14545 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14546 692 {
14547 692 id=misc=clk;
14548 692 dir = clk & 3;
14549 692 clk=0;
14550 692 mainguy=count_enemy=false;
14551 692 dummy_bool[0]=false;
14552 692 item_set=0;
14553 692 bgsfx=-1;
14554 692 deadsfx = WAV_EDEAD;
14555
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14556 692 isCore = false;
14557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14558 692 }
14559
14560 200202 bool esManhandla::animate(int32_t index)
14561 {
14562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14563
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14564 7008 return Dead(index);
14565
14566
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14567 {
14568 12404 removearmos(x,y);
14569 12404 }
14570
14571
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14572 {
14573 27896 clk2=unsigned(zc_oldrand())%5+5;
14574 27896 clk3^=1;
14575 27896 }
14576
14577
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14578 {
14579 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14580 1491 sfx(wpnsfx(wpn),pan(x));
14581 1491 }
14582
14583 193194 return enemy::animate(index);
14584 200202 }
14585
14586 200186 void esManhandla::draw(BITMAP *dest)
14587 {
14588 200186 tile=o_tile;
14589 200186 int32_t fdiv = frate/4;
14590
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14591
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14592 200186 efrate:((clk>=(frate>>1))?1:0);
14593
14594
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14595 {
14596
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14597 {
14598 case up:
14599 39945 break;
14600
14601 case down:
14602 36845 tile+=4;
14603 36845 break;
14604
14605 case left:
14606 39966 tile+=8;
14607 39966 break;
14608
14609 case right:
14610 41960 tile+=12;
14611 41960 break;
14612 }
14613
14614 158716 tile+=f2;
14615 158716 }
14616 else
14617 {
14618
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14619 {
14620 case down:
14621 8961 flip=2;
14622
14623 [[fallthrough]];
14624 case up:
14625 21355 tile=(clk3)?188:189;
14626 21355 break;
14627
14628 case right:
14629 12232 flip=1;
14630 [[fallthrough]];
14631
14632 case left:
14633 20115 tile=(clk3)?186:187;
14634 20115 break;
14635 }
14636 }
14637
14638 200186 enemy::draw(dest);
14639 200186 }
14640
14641 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14642 168 {
14643
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
14644 {
14645
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14646 168 }
14647 else
14648 {
14649 if ( !(editorflags & ENEMY_FLAG6) )
14650 {
14651 x = X; y = Y;
14652 }
14653 else
14654 {
14655 x = X+8; y = Y;
14656 }
14657 }
14658 168 hzsz = 32; // can't be jumped.
14659 168 flameclk=0;
14660 168 misc=clk; // total head count
14661 168 clk3=clk; // live head count
14662 168 clk=0;
14663 168 clk2=60; // fire ball clock
14664 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14665
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14666 168 dir = down;
14667 168 hxofs=4;
14668 168 hit_width=8;
14669 // frate=17*4;
14670 168 fading=fade_blue_poof;
14671 //nets+5420;
14672
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
14673 {
14674 /*
14675 necktile=o_tile+8;
14676 if (dmisc3)
14677 {
14678 necktile+=8;
14679 }
14680 */
14681 133 necktile=o_tile+dmisc6;
14682 133 }
14683 else
14684 {
14685 35 necktile=s_tile;
14686 }
14687 168 }
14688
14689 155290 bool eGleeok::animate(int32_t index)
14690 {
14691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
14692
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
14693 2199 return Dead(index);
14694
14695
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
14696 {
14697 684 removearmos(x,y);
14698 684 }
14699
14700 // Check if a head was killed somehow...
14701
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
14702 51372 clk3=guys.Count()-index-1;
14703
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
14704 87041 misc=guys.Count()-index-1;
14705
14706 //fix for the "kill all enemies" item
14707
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
14708 {
14709
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14710 {
14711 // I haven't seen this fail, but it seems like it ought to be
14712 // possible, so I'm checking for it. - Saf
14713
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14714 break;
14715 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14716 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14717 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14718 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14719 12 }
14720
14721 6 clk3=0;
14722
14723
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14724 {
14725
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14726 break;
14727 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14728 12 }
14729 6 }
14730
14731
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
14732 {
14733 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
14734 403171 head->dummy_int[1]=necktile;
14735 403171 head->setParent(this);
14736
14737
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
14738 {
14739 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14740 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14741 320127 }
14742 else
14743 {
14744 83044 head->dummy_int[2]=necktile+1; //connected head tile
14745 83044 head->dummy_int[3]=necktile+2; //flying head tile
14746 }
14747
14748 403171 head->dmisc5=dmisc5; //neck segments
14749
14750 /*
14751 if (dmisc3)
14752 {
14753 head->dummy_bool[0]=true;
14754 }
14755 */
14756
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
14757 {
14758
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
14759 {
14760 1228 hp -= 1000 - head->hp;
14761 1228 hclk = 33;
14762
14763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14764
14765 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
14766 1228 }
14767
14768 5655 head->hclk = 0;
14769 5655 }
14770
14771 // Must be set in case of naughty ZScripts
14772 403171 head->hp = 1000;
14773 403171 }
14774
14775
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14776 {
14777 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14778 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14779 415 }
14780
14781
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
14782 {
14783
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14784 {
14785 1287 int32_t i = zc::math::SafeMod(zc_oldrand(), misc);
14786 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14787 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14788 1287 sfx(wpnsfx(wpn),pan(x));
14789 1287 clk2=0;
14790 1287 }
14791 95682 }
14792 else
14793 {
14794
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
14795 {
14796 557 enemy *head = ((enemy*)guys.spr(zc::math::SafeMod(zc_oldrand(), misc) + index + 1));
14797 557 head->timer=zc_oldrand()%50+50;
14798 557 clk2=0;
14799 557 }
14800 }
14801
14802
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
14803 {
14804
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
14805 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14806
14807
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(screen_spawned, index);
14808 127 }
14809
14810 153091 return enemy::animate(index);
14811 155290 }
14812
14813 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14814 {
14815 1239 return 0;
14816 }
14817
14818 156918 void eGleeok::draw(BITMAP *dest)
14819 {
14820 156918 tile=o_tile;
14821
14822
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
14823 {
14824 2199 enemy::draw(dest);
14825 2199 return;
14826 }
14827
14828 154719 int32_t f=clk/17;
14829
14830
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
14831 {
14832 // body
14833 120524 xofs=-8;
14834 120524 yofs=32;
14835
14836
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
14837
14838 {
14839 case 0:
14840 9155 tile+=0;
14841 9155 break;
14842
14843 case 1:
14844 10095 tile+=2;
14845 10095 break;
14846
14847 case 2:
14848 8686 tile+=4;
14849 8686 break;
14850
14851 default:
14852 92588 tile+=6;
14853 92588 break;
14854 }
14855 120524 }
14856 else
14857 {
14858 // body
14859 34195 xofs=-8;
14860 34195 yofs=32;
14861
14862
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14863 {
14864 case 0:
14865 2514 tile+=0;
14866 2514 break;
14867
14868 case 2:
14869 2459 tile+=4;
14870 2459 break;
14871
14872 default:
14873 29222 tile+=2;
14874 29222 break;
14875 }
14876 }
14877
14878 154719 enemy::drawblock(dest,15);
14879 156918 }
14880
14881 156918 void eGleeok::draw2(BITMAP *dest)
14882 {
14883 // the neck stub
14884 156918 tile=necktile;
14885 156918 xofs=0;
14886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14887
14888
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
14889 {
14890 122181 tile+=((clk&24)>>3);
14891 122181 }
14892
14893
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
14894 {
14895 154719 mapscr* scr = get_scr(screen_spawned);
14896
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
14897 737 sprite::drawcloaked(dest);
14898 else
14899 153982 sprite::draw(dest);
14900 154719 }
14901 156918 }
14902
14903
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
14904 533 {
14905
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 setParent(prnt);
14906
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
14907
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
14908 // dummy_bool[0]=false;
14909 533 timer=0;
14910 /* fixing */
14911 533 hp=1000;
14912
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
14913 533 item_set=0;
14914
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
14915
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
14916 533 hxofs=4;
14917 533 hit_width=8;
14918
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14919 533 clk2=clk; // how int32_t to wait before moving first time
14920 533 clk=0;
14921 533 mainguy=count_enemy=false;
14922
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
14923 533 clk3=((dir&2)>>1)+2; // left or right
14924 533 dir&=1; // up or down
14925
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
14926 533 isCore = false;
14927
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
14928
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
14929 {
14930 2132 nxoffset[i] = 0;
14931 2132 nyoffset[i] = 0;
14932
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
14933
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
14934 2132 }
14935
14936 533 necktile=0;
14937 //TODO compatibility? -DD
14938 /*
14939 for(int32_t i=0; i<4; i++)
14940 {
14941 nx[i]=124;
14942 ny[i]=i*6+48;
14943 }*/
14944 533 bgsfx=-1;
14945 //no need for deadsfx
14946 533 }
14947
14948 515535 bool esGleeok::animate(int32_t index)
14949 {
14950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
14951 // don't call removearmos() - it's a segment.
14952
14953 515535 dmisc5=vbound(dmisc5,1,255);
14954
14955
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
14956 {
14957 402762 x = (xoffset+parent->x);
14958 402762 y = (yoffset+parent->y);
14959
14960
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
14961 {
14962 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
14963 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
14964 1611048 }
14965 402762 }
14966
14967 // set up the head tiles
14968 // headtile=nets+5588; //5580, actually. must adjust for direction later on
14969 /*
14970 if (dummy_bool[0]) //if this is a flame gleeok
14971 {
14972 headtile+=180;
14973 }
14974 */
14975 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
14976 515535 flyingheadtile=dummy_int[3];
14977
14978 // set up the neck tiles
14979 515535 necktile=dummy_int[1];
14980
14981
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
14982 {
14983 402833 necktile+=((clk&24)>>3);
14984 402833 }
14985
14986 /*
14987 else
14988 {
14989 necktile=145;
14990 }
14991 */
14992 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
14993
14994
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
14995 {
14996 case 0: // live head
14997 // set up the attached head tiles
14998 402762 tile=headtile;
14999
15000
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15001 {
15002 319820 tile+=((clk&24)>>3);
15003 /*
15004 if (dummy_bool[0]) {
15005 tile+=1561;
15006 }
15007 */
15008 319820 }
15009
15010 /*
15011 else
15012 {
15013 tile=146;
15014 }
15015 */
15016
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15017 {
15018
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15019
15020
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15021
15022
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15023 {
15024 292 dir^=1;
15025 292 }
15026
15027 92832 zfix tempx = x;
15028 92832 zfix tempy = y;
15029
15030 92832 sprite::move(step);
15031 92832 xoffset += (x-tempx);
15032 92832 yoffset += (y-tempy);
15033
15034
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15035 {
15036 3863 clk3^=1;
15037 3863 clk2=-4;
15038 3863 }
15039 else
15040 {
15041
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15042 {
15043 978 clk3=right;
15044 978 }
15045
15046
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15047 {
15048 961 clk3=left;
15049 961 }
15050
15051
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15052 {
15053 3713 clk3^=1; // x jig
15054 3713 }
15055 else
15056 {
15057
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15058 {
15059 851 clk3^=1; // x switch back
15060 851 }
15061
15062 85256 clk2=-4;
15063 }
15064 }
15065
15066 92832 zc_swap(dir,clk3);
15067 92832 tempx = x;
15068 92832 tempy = y;
15069 92832 sprite::move(step);
15070 92832 xoffset += (x-tempx);
15071 92832 yoffset += (y-tempy);
15072 92832 zc_swap(dir,clk3);
15073
15074
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15075 {
15076 278496 nxoffset[i] = (zc_oldrand()%3);
15077 278496 nyoffset[i] = (zc_oldrand()%3);
15078 278496 }
15079 92832 }
15080
15081 402762 break;
15082
15083 case 1: // flying head
15084
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15085
15086 {
15087 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15088 105482 }
15089
15090 112071 break;
15091
15092 // the following are messages sent from the main guy...
15093 case -1: // got chopped off
15094 {
15095 300 misc=1;
15096 300 superman=1;
15097 300 hxofs=xofs=0;
15098 300 hit_width=16;
15099 300 cs=8;
15100 300 clk=-24;
15101 300 clk2=40;
15102 300 dir=(zc_oldrand()&7)+8;
15103 300 step=8.0/9.0;
15104 }
15105 300 break;
15106
15107 case -2: // the big guy is dead
15108 402 return true;
15109 }
15110
15111
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15112 {
15113
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15114 {
15115 4791 FireBreath(true);
15116 4791 }
15117
15118 40125 --timer;
15119 40125 }
15120
15121 515133 return enemy::animate(index);
15122 515535 }
15123
15124 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15125 {
15126
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15127 {
15128 int32_t wpnId = w->id;
15129
15130 if(dying)
15131 return 0;
15132
15133 switch(wpnId)
15134 {
15135 case wLitBomb:
15136 case wLitSBomb:
15137 case wBait:
15138 case wWhistle:
15139 case wFire:
15140 case wWind:
15141 case wSSparkle:
15142 case wFSparkle:
15143 case wPhantom:
15144 return 0;
15145
15146 case wHookshot:
15147 case wBrang:
15148 case wBeam:
15149 case wArrow:
15150 case wMagic:
15151 case wBomb:
15152 case wSBomb:
15153 sfx(WAV_CHINK,pan(x));
15154 break;
15155 default:
15156 break;
15157 }
15158
15159 return 1;
15160 }
15161 else
15162 {
15163 7080 int32_t ret = enemy::takehit(w,realweap);
15164
15165
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15166 5655 return -2; // force it to wait a frame before checking sword attacks again
15167
15168 1425 return ret;
15169 }
15170 7080 }
15171
15172 521456 void esGleeok::draw(BITMAP *dest)
15173 {
15174 521456 dmisc5=vbound(dmisc5,1,255);
15175
15176
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15177 {
15178 case 0: //neck
15179
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15180 {
15181
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15182 {
15183 1227318 mapscr* scr = get_scr(screen_spawned);
15184
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15185 {
15186
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15187 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15188 else
15189 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15190 978198 }
15191 else
15192 {
15193
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15194 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15195 else
15196 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15197 }
15198 1227318 }
15199 409106 }
15200
15201 409106 break;
15202
15203 case 1: //flying head
15204 112350 tile=flyingheadtile;
15205
15206
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15207 {
15208 82692 tile+=((clk&24)>>3);
15209 82692 break;
15210 }
15211 29658 }
15212 521456 }
15213
15214 521456 void esGleeok::draw2(BITMAP *dest)
15215 {
15216 521456 enemy::draw(dest);
15217 521456 }
15218
15219 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15220 190 {
15221
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15222 {
15223
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15224
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15225 190 }
15226 else { x = X; y = Y; }
15227 190 adjusted=false;
15228
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15229 //step=0.25;
15230 190 flycnt=dmisc1;
15231 190 flycnt2=dmisc2;
15232 190 loopcnt=0;
15233 190 clk4 = 0;
15234 190 clk5 = 0;
15235 190 clk6 = 0;
15236 190 clk7 = 0;
15237
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15239 {
15240
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15241 {
15242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15243 105 else dmisc29 = (84 / 3);
15244 105 }
15245 else
15246 {
15247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15248 85 else dmisc29 = (84 / 2);
15249 }
15250 190 }
15251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15252 {
15253
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15254 {
15255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15256 105 else dmisc30 = (84 / 3)*0.5;
15257 105 }
15258 else
15259 {
15260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15261 85 else dmisc30 = (84 / 2)*0.5;
15262 }
15263 190 }
15264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15265 {
15266
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15267 {
15268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15269 105 else dmisc31 = (84 / 3)*2;
15270 105 }
15271 else
15272 {
15273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15274 85 else dmisc31 = (84 / 2)*0.5;
15275 }
15276 190 }
15277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15278 {
15279
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15280 {
15281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15282 105 else dmisc32 = (84 / 3);
15283 105 }
15284 else
15285 {
15286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15287 85 else dmisc32 = (84 / 2)*0.25;
15288 }
15289 190 }
15290
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15291 190 }
15292
15293 161885 bool ePatra::animate(int32_t index)
15294 {
15295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15296
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15297 {
15298
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15299 {
15300 72 auto segment = (enemy*)guys.spr(i);
15301
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
72 if (segment && segment->parent == this)
15302 72 segment->hp = -1000;
15303 72 }
15304
15305 1444 return Dead(index);
15306 }
15307
15308 160441 double basesize = 84;
15309
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15310 160441 double halfsize = basesize / 2;
15311 160441 double quartersize = halfsize / 2;
15312 160441 double twothirdsize = (basesize / 3)*2;
15313 160441 double onethirdsize = (basesize / 3);
15314
15315
15316
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15317 {
15318 36934 removearmos(x,y);
15319 36934 }
15320
15321
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15322 {
15323
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15324
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15325
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15326 {
15327 1797 clk2=0;
15328
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15329 {
15330
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15331 932 --loopcnt;
15332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15333 {
15334
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if (zc::math::SafeMod(misc, dmisc6) == 0)
15335 {
15336
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15337 356 else loopcnt=dmisc7;
15338 356 }
15339 865 }
15340 else if (loopcnt == -1) loopcnt=dmisc7;
15341 else ++loopcnt;
15342
15343
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15344 1797 }
15345 else
15346 {
15347 loopcnt = 0;
15348 misc = 1;
15349 }
15350 1797 }
15351 160441 }
15352
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15353
15354
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15355 {
15356 if (dmisc5 == 1 || dmisc5 == 3)
15357 {
15358 if (get_qr(qr_NEWENEMYTILES))
15359 {
15360 if (clk7 <= 0 || clk6 != -16) ++clk6;
15361 if (clk6 == 0) o_tile=d->e_tile;
15362 else
15363 {
15364 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15365 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15366 }
15367 }
15368 else clk6 = 0;
15369 }
15370 }
15371
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15372
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15373
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15374
15375
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15376
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15377
15378
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15379 {
15380 //outside ring
15381
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15382 {
15383
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15384 {
15385 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15386 1152 enemy *s = ((enemy*)guys.spr(i));
15387 1152 s->setParent(this);
15388 1152 }
15389 else
15390 {
15391 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15392 192 enemy *s = ((enemy*)guys.spr(i));
15393 192 s->setParent(this);
15394 }
15395
15396 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15397 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15398 1344 }
15399
15400
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15401 {
15402
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15403 {
15404 2889 guys.swap(j,j+1);
15405 2889 }
15406
15407
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15408 764 }
15409 else
15410 {
15411 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15412
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15413
15414
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15415 {
15416 //maybe playing_field_offset here?
15417
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15418 {
15419
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15420
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15421 237330 }
15422 else
15423 {
15424 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15425 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15426 }
15427
15428 447583 temp_x=guys.spr(i)->x;
15429 447583 temp_y=guys.spr(i)->y;
15430 447583 }
15431 else //Oval
15432 {
15433 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15434 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15435
15436
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15437 {
15438 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15439
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15440 121041 }
15441 else
15442 {
15443 90996 guys.spr(i)->x = circle_x;
15444 90996 guys.spr(i)->y = circle_y;
15445 }
15446
15447 212037 temp_x=circle_x;
15448 212037 temp_y=circle_y;
15449 }
15450
15451 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15452 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15453
15454
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15455 {
15456 83117 guys.spr(i)->dir=l_down;
15457 83117 }
15458
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15459 {
15460 83568 guys.spr(i)->dir=left;
15461 83568 }
15462
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15463 {
15464 82454 guys.spr(i)->dir=l_up;
15465 82454 }
15466
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15467 {
15468 82188 guys.spr(i)->dir=up;
15469 82188 }
15470
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15471 {
15472 81600 guys.spr(i)->dir=r_up;
15473 81600 }
15474
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15475 {
15476 81993 guys.spr(i)->dir=right;
15477 81993 }
15478
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15479 {
15480 81699 guys.spr(i)->dir=r_down;
15481 81699 }
15482 else
15483 {
15484 83001 guys.spr(i)->dir=down;
15485 }
15486
15487 659620 guys.spr(i)->x += x;
15488 659620 guys.spr(i)->y += y;
15489 }
15490 660384 }
15491
15492
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15493 {
15494 32331 int timeneeded = 48;
15495 32331 int patbreath = (zc_oldrand()%50+50);
15496
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15497
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15498 {
15499 timeneeded = 48 + patbreath;
15500 }
15501
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15502 {
15503 timeneeded = 48 + 96;
15504 }
15505
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15506
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15507
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15508 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15509 249 && (clk6 >= 0) //if not in the middle of firing...
15510 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15511
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15512 {
15513
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15514 {
15515 case patratSTREAM:
15516 {
15517 clk7 = 97;
15518 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15519 else clk6 = 0;
15520 break;
15521 }
15522 case patratBREATH:
15523 {
15524 clk7 = patbreath;
15525 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15526 else clk6 = 0;
15527 break;
15528 }
15529 default:
15530 {
15531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15532 {
15533 clk6 = -48;
15534 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15535 }
15536 else
15537 {
15538 249 clk6 = 0;
15539
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15540 249 FirePatraWeapon();
15541 }
15542 249 break;
15543 }
15544 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15545 249 }
15546
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15547 {
15548 switch(dmisc28)
15549 {
15550 case patratSTREAM:
15551 {
15552 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15553 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15554 break;
15555 }
15556 case patratBREATH:
15557 {
15558 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15559 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15560 break;
15561 }
15562 default:
15563 {
15564 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15565 {
15566 FirePatraWeapon();
15567 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15568 }
15569 break;
15570 }
15571 }
15572 }
15573 32331 }
15574
15575 160441 int randattempts = 0;
15576 160441 int randeye = 0;
15577
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15578 {
15579 46240 do
15580 {
15581
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15582 46240 randeye += (index + flycnt + 1);
15583 46240 ++randattempts;
15584
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15585 46240 }
15586 160441 bool dofire = false;
15587
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15588 {
15589 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15590 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15591 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15592 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15593 || (((((zc::math::SafeMod(misc, dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15594 {
15595 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15596 {
15597 if (clk5 >= dmisc19)
15598 {
15599 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15600 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15601 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + 96)) ||
15602 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48)))
15603 || dmisc18 == -1)
15604 dofire = true;
15605 }
15606 }
15607 }
15608 }
15609
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
15610 {
15611
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15612 {
15613
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15614 {
15615 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15616
15617
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15618 {
15619
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15620 {
15621
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
15622 {
15623 // Center eye shoots projectiles; make room for its firing tiles
15624 case 1:
15625 case 3:
15626 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15627 144 break;
15628
15629 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15630 default:
15631 case 2:
15632 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15633 168 break;
15634 }
15635 312 }
15636 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15637 312 }
15638 else
15639 {
15640 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15641 }
15642
15643 312 ((enemy*)guys.spr(i))->cs=dmisc9;
15644
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15645 312 }
15646
15647
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
15648 {
15649 263816 ((enemy*)guys.spr(i))->superman=true;
15650 263816 }
15651 else
15652 {
15653 70613 ((enemy*)guys.spr(i))->superman=false;
15654 }
15655
15656
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
15657 {
15658
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15659 {
15660 269 guys.swap(j,j+1);
15661 269 }
15662
15663
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15664 145 }
15665 else
15666 {
15667 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15668
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15669
15670
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
15671 {
15672
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
15673 {
15674
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15675
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15676 168378 }
15677 else
15678 {
15679 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15680 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15681 }
15682
15683 327025 temp_x=guys.spr(i)->x;
15684 327025 temp_y=guys.spr(i)->y;
15685 327025 }
15686 else
15687 {
15688 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15689 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15690
15691
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15692 {
15693 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15694
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15695 3965 }
15696 else
15697 {
15698 3294 guys.spr(i)->x = circle_x;
15699 3294 guys.spr(i)->y = circle_y;
15700 }
15701
15702 7259 temp_x=circle_x;
15703 7259 temp_y=circle_y;
15704 }
15705
15706 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15707 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15708
15709
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15710 {
15711 41746 guys.spr(i)->dir=l_down;
15712 41746 }
15713
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15714 {
15715 41734 guys.spr(i)->dir=left;
15716 41734 }
15717
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15718 {
15719 41742 guys.spr(i)->dir=l_up;
15720 41742 }
15721
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15722 {
15723 41758 guys.spr(i)->dir=up;
15724 41758 }
15725
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15726 {
15727 41830 guys.spr(i)->dir=r_up;
15728 41830 }
15729
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15730 {
15731 41824 guys.spr(i)->dir=right;
15732 41824 }
15733
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15734 {
15735 41852 guys.spr(i)->dir=r_down;
15736 41852 }
15737 else
15738 {
15739 41798 guys.spr(i)->dir=down;
15740 }
15741
15742 334284 guys.spr(i)->x += x;
15743 334284 guys.spr(i)->y = y-guys.spr(i)->y;
15744
15745
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15746 {
15747 /*
15748 if(!(zc_oldrand()&127))
15749 {
15750 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15751 sfx(wpnsfx(wpn),pan(x));
15752 }
15753 */
15754
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15755 {
15756 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15757 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15758 {
15759 if (dmisc5 == 3)
15760 {
15761 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15762 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15763 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15764 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15765 }
15766 else
15767 {
15768 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15769 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15770 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15771 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15772 }
15773 }
15774 else
15775 {
15776 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15777 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15778 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15779 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15780 }
15781 }
15782
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15783
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15784
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15785 {
15786
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15787 {
15788 case 4: //Single one rapidfires
15789 {
15790 if (dofire && i == randeye)
15791 {
15792 ((esPatra*)guys.spr(i))->clk5 = -16;
15793 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15794 ((esPatra*)guys.spr(i))->clk4 = 96;
15795 clk5 = -3;
15796 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15797 }
15798 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15799 {
15800 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15801 sfx(wpnsfx(wpn),pan(x));
15802 }
15803 break;
15804 }
15805 case 3: //Ring
15806 {
15807 if (dofire)
15808 {
15809 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15810 {
15811 ((esPatra*)guys.spr(i))->clk5 = -48;
15812 clk5 = -48;
15813 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15814 }
15815 else
15816 {
15817 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15818 sfx(wpnsfx(wpn),pan(x));
15819 int32_t m=Ewpns.Count()-1;
15820 weapon *ew = (weapon*)(Ewpns.spr(m));
15821
15822 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15823 ((esPatra*)guys.spr(i))->clk5 = 0;
15824 clk5 = 0;
15825 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15826 }
15827 }
15828 if (((esPatra*)guys.spr(i))->clk5 == -16)
15829 {
15830 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15831 sfx(wpnsfx(wpn),pan(x));
15832 int32_t m=Ewpns.Count()-1;
15833 weapon *ew = (weapon*)(Ewpns.spr(m));
15834
15835 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15836 }
15837 break;
15838 }
15839 case 2: //one after another
15840 {
15841 if (dofire)
15842 {
15843 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15844 clk5 = -48 - (12*flycnt2);
15845 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15846 }
15847 if (((esPatra*)guys.spr(i))->clk5 == -16)
15848 {
15849 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15850 sfx(wpnsfx(wpn),pan(x));
15851 }
15852 break;
15853 }
15854 case 1: //random one eye
15855 {
15856 if (dofire && i == randeye)
15857 {
15858 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15859 {
15860 ((esPatra*)guys.spr(i))->clk5 = -48;
15861 clk5 = -48;
15862 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15863 }
15864 else
15865 {
15866 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15867 sfx(wpnsfx(wpn),pan(x));
15868 ((esPatra*)guys.spr(i))->clk5 = 0;
15869 clk5 = 0;
15870 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15871 }
15872 }
15873 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15874 {
15875 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15876 sfx(wpnsfx(wpn),pan(x));
15877 }
15878 break;
15879 }
15880 default: //old behavior, all eyes can fire any time
15881 {
15882
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15883
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15884
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15885 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48))))
15886 {
15887
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15888 {
15889 ((esPatra*)guys.spr(i))->clk5 = -48;
15890 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15891 }
15892 else
15893 {
15894 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15895 1155 sfx(wpnsfx(wpn),pan(x));
15896 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
15897
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15898 }
15899 1155 }
15900
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15901 {
15902 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15903 sfx(wpnsfx(wpn),pan(x));
15904 }
15905 145268 break;
15906 }
15907 }
15908 145268 }
15909 145268 }
15910
15911 }
15912 334429 }
15913 46240 }
15914
15915 160441 adjusted=true;
15916 160441 return enemy::animate(index);
15917 161885 }
15918
15919 249 void ePatra::FirePatraWeapon()
15920 { //.707
15921 249 int32_t xoff = 0;
15922 249 int32_t yoff = 0;
15923
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
15924 {
15925 xoff += hxofs;
15926 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
15927 xoff += (hit_width / 2) - (weap_data.tilew * 8);
15928 else
15929 xoff += (hit_width / 2) - 8;
15930 }
15931
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
15932 {
15933 yoff += hyofs;
15934 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
15935 yoff += (hit_height / 2) - (weap_data.tileh * 8);
15936 else
15937 yoff += (hit_height / 2) - 8;
15938 }
15939 249 sfx(wpnsfx(wpn),pan(x));
15940 // TODO(crash): check that .add succeeds.
15941
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
15942 {
15943 case patrat8SHOT: //Fire Wizzrobe
15944 case patrat4SHOTDIAG:
15945 case patrat4SHOTRAND:
15946 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
15947 {
15948 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
15949 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
15950 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
15951 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
15952
15953 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
15954 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
15955 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
15956 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
15957
15958 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
15959 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
15960 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
15961 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
15962
15963 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
15964 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
15965 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
15966 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
15967
15968 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
15969 }
15970
15971 [[fallthrough]];
15972 case patrat4SHOTCARD: //Stalfos 3
15973 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
15974 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
15975 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
15976 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
15977 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
15978 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
15979 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
15980 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
15981 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
15982 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
15983 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
15984 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
15985 break;
15986
15987 default:
15988 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
15989
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
15990 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
15991
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
15992
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
15993 {
15994 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
15995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
15996 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
15997 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
15998 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
15999 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16000 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16001 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16002 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16003 {
16004 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16005 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16006 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16007 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16008 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16009 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16010 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16011 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16012 }
16013 }
16014 249 break;
16015
16016 }
16017 249 sfx(wpnsfx(wpn),pan(x));
16018 //+0.46364761
16019 //11.80
16020 249 }
16021
16022 324242 void ePatra::draw(BITMAP *dest)
16023 {
16024 324242 tile=o_tile;
16025 324242 update_enemy_frame();
16026 324242 enemy::draw(dest);
16027 324242 }
16028
16029 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16030 {
16031 int32_t ret = enemy::defend(wpnId, power, edef);
16032
16033 if(ret < 0 && (flycnt||flycnt2))
16034 return 0;
16035
16036 return ret;
16037 }
16038
16039 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16040 {
16041 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16042
16043
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16044 1281 return 0;
16045
16046 452 return ret;
16047 1733 }
16048
16049 190 void ePatra::init_size_flags() {
16050 190 SIZEflags = d->SIZEflags;
16051
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16052
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16053 // al_trace("Enemy txsz:%i\n", txsz);
16054
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16055
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16056
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16057
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16058
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16059
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16061
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16062
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16063 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16065
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16067 {
16068 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16069 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16070 }
16071
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16072
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16073
16074
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16075
16076 190 }
16077
16078 1656 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16079 1656 {
16080 //cs=8;
16081
1/2
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
1656 setParent(prnt);
16082 1656 item_set=0;
16083 1656 misc=clk;
16084 1656 clk4 = 0;
16085 1656 clk5 = 0;
16086 1656 clk = -((misc*21)>>1)-1;
16087
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16088 1656 hit_width=12;
16089 1656 hit_height=12;
16090 1656 hxofs=2;
16091 1656 hyofs=2;
16092 1656 extend = 0;
16093 1656 txsz = 1;
16094 1656 tysz = 1;
16095 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16096 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16097 int32_t prntSIZEflags = prntenemy->SIZEflags;
16098 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16099 // al_trace("Enemy txsz:%i\n", txsz);
16100 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16101 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16102 else
16103 hxsz=12;
16104 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16105 else
16106 hysz=12;
16107 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16108 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16109 else
16110 hxofs=2;
16111 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16112 else hyofs=2;
16113 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16114 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16115 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16116 {
16117 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16118 }
16119
16120 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16121 */
16122 1656 mainguy=count_enemy=false;
16123 1656 bgsfx=-1;
16124 //o_tile=0;
16125
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16126 1656 deadsfx = WAV_EDEAD;
16127 1656 hitsfx = WAV_EHIT;
16128 1656 isCore = false;
16129 1656 }
16130
16131 1010584 bool esPatra::animate(int32_t index)
16132 {
16133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16134
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16135 15160 return Dead(index);
16136
16137 995424 return enemy::animate(index);
16138 1010584 }
16139
16140 2028196 void esPatra::draw(BITMAP *dest)
16141 {
16142
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16143 {
16144 1721294 tile = o_tile+(clk&3);
16145
16146
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16147 {
16148 case up: //u
16149 214278 flip=0;
16150 214278 break;
16151
16152 case down: //d
16153 217924 flip=0;
16154 217924 tile+=4;
16155 217924 break;
16156
16157 case left: //l
16158 215346 flip=0;
16159 215346 tile+=8;
16160 215346 break;
16161
16162 case right: //r
16163 215726 flip=0;
16164 215726 tile+=12;
16165 215726 break;
16166
16167 case l_up: //ul
16168 213062 flip=0;
16169 213062 tile+=20;
16170 213062 break;
16171
16172 case r_up: //ur
16173 214350 flip=0;
16174 214350 tile+=24;
16175 214350 break;
16176
16177 case l_down: //dl
16178 215734 flip=0;
16179 215734 tile+=28;
16180 215734 break;
16181
16182 case r_down: //dr
16183 214874 flip=0;
16184 214874 tile+=32;
16185 214874 break;
16186 }
16187 1721294 }
16188 else
16189 {
16190 306902 tile = o_tile+((clk&2)>>1);
16191 }
16192
16193
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16194 1913340 enemy::draw(dest);
16195 2028196 }
16196
16197
16198 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16199 102 {
16200 102 adjusted=false;
16201
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16202
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16203 102 clk4 = 0;
16204 102 clk5 = 0;
16205 //flycnt=6; flycnt2=0;
16206 102 flycnt=dmisc1;
16207 102 flycnt2=0; // PatraBS doesn't have inner rings!
16208 102 loopcnt=0;
16209
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16211
16212 //nets+4480;
16213 102 }
16214
16215 35963 bool ePatraBS::animate(int32_t index)
16216 {
16217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16218
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16219 240 return Dead(index);
16220
16221
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16222 {
16223 4018 removearmos(x,y);
16224 4018 }
16225
16226 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16227
16228
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16229 {
16230 336 clk2=0;
16231
16232
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16233 177 --loopcnt;
16234 else
16235 {
16236
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if(zc::math::SafeMod(misc, dmisc6)==0)
16237 84 loopcnt=dmisc7;
16238 }
16239
16240 336 ++misc;
16241 336 }
16242
16243 // double size=1;;
16244
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16245 {
16246
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16247 {
16248 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16249
16250
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16251 {
16252 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16253 612 }
16254 else
16255 {
16256 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16257 }
16258
16259 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16260 612 }
16261
16262
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16263 {
16264
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16265 {
16266 131 guys.swap(j,j+1);
16267 131 }
16268
16269 104 --flycnt;
16270 104 }
16271 else
16272 {
16273 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16274
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16275 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16276 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16277
16278
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16279 {
16280 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16281
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16282 77643 }
16283 else
16284 {
16285 75725 guys.spr(i)->x = temp_x;
16286 75725 guys.spr(i)->y = temp_y;
16287 }
16288
16289 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16290 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16291
16292
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16293 {
16294 18812 guys.spr(i)->dir=l_down;
16295 18812 }
16296
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16297 {
16298 18839 guys.spr(i)->dir=left;
16299 18839 }
16300
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16301 {
16302 18802 guys.spr(i)->dir=l_up;
16303 18802 }
16304
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16305 {
16306 20143 guys.spr(i)->dir=up;
16307 20143 }
16308
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16309 {
16310 18517 guys.spr(i)->dir=r_up;
16311 18517 }
16312
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16313 {
16314 18779 guys.spr(i)->dir=right;
16315 18779 }
16316
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16317 {
16318 18992 guys.spr(i)->dir=r_down;
16319 18992 }
16320 else
16321 {
16322 20484 guys.spr(i)->dir=down;
16323 }
16324
16325 153368 guys.spr(i)->x += x;
16326 153368 guys.spr(i)->y += y;
16327 }
16328 153472 }
16329
16330 35723 adjusted=true;
16331 35723 return enemy::animate(index);
16332 35963 }
16333
16334 72874 void ePatraBS::draw(BITMAP *dest)
16335 {
16336 72874 tile=o_tile;
16337
16338
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16339 {
16340 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16341 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16342
16343
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16344 {
16345 19146 lookat=l_down;
16346 19146 }
16347
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16348 {
16349 18298 lookat=down;
16350 18298 }
16351
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16352 {
16353 13624 lookat=r_down;
16354 13624 }
16355
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16356 {
16357 7492 lookat=right;
16358 7492 }
16359
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16360 {
16361 1170 lookat=r_up;
16362 1170 }
16363
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16364 {
16365 964 lookat=up;
16366 964 }
16367
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16368 {
16369 1700 lookat=l_up;
16370 1700 }
16371 else
16372 {
16373 10480 lookat=left;
16374 }
16375
16376
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16377 {
16378 case up: //u
16379 964 flip=0;
16380 964 break;
16381
16382 case down: //d
16383 18298 flip=0;
16384 18298 tile+=8;
16385 18298 break;
16386
16387 case left: //l
16388 10480 flip=0;
16389 10480 tile+=40;
16390 10480 break;
16391
16392 case right: //r
16393 7492 flip=0;
16394 7492 tile+=48;
16395 7492 break;
16396
16397 case l_up: //ul
16398 1700 flip=0;
16399 1700 tile+=80;
16400 1700 break;
16401
16402 case r_up: //ur
16403 1170 flip=0;
16404 1170 tile+=88;
16405 1170 break;
16406
16407 case l_down: //dl
16408 19146 flip=0;
16409 19146 tile+=120;
16410 19146 break;
16411
16412 case r_down: //dr
16413 13624 flip=0;
16414 13624 tile+=128;
16415 13624 break;
16416 }
16417
16418 72874 tile+=(2*(clk&3));
16419 72874 xofs-=8;
16420 72874 yofs-=8;
16421 72874 drawblock(dest,15);
16422 72874 xofs+=8;
16423 72874 yofs+=8;
16424 72874 }
16425 else
16426 {
16427 flip=(clk&1);
16428 xofs-=8;
16429 yofs-=8;
16430 enemy::draw(dest);
16431 xofs+=16;
16432 enemy::draw(dest);
16433 yofs+=16;
16434 enemy::draw(dest);
16435 xofs-=16;
16436 enemy::draw(dest);
16437 xofs+=8;
16438 yofs-=8;
16439 }
16440 72874 }
16441
16442 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16443 {
16444 int32_t ret = enemy::defend(wpnId, power, edef);
16445
16446 if(ret < 0 && (flycnt||flycnt2))
16447 return 0;
16448
16449 return ret;
16450 }
16451
16452 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16453 {
16454 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16455
16456
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16457 81 return 0;
16458
16459 61 return ret;
16460 142 }
16461
16462 102 void ePatraBS::init_size_flags()
16463 {
16464 102 SIZEflags = d->SIZEflags;
16465
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16466 // al_trace("Enemy txsz:%i\n", txsz);
16467
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16468
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16469 102 else hit_width = 32;
16470
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16471
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16473 102 else hxofs = -8;
16474
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16475 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16476
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16477
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16478 {
16479 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16480 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16481 }
16482
16483
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16484 102 }
16485
16486 612 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16487 612 {
16488 //cs=csBOSS;
16489
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 setParent(prnt);
16490 612 item_set=0;
16491 612 misc=clk;
16492 612 clk = -((misc*21)>>1)-1;
16493 612 clk4 = 0;
16494 612 clk5 = 0;
16495
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16496 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16497
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16498 // al_trace("Enemy txsz:%i\n", txsz);
16499
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16500
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16501 612 else hit_width=16;
16502
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16503 612 else hit_height=16;
16504
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16505
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16507 612 else hyofs=2;
16508 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16509
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16511 {
16512 yofs = (int32_t)prntenemy->yofs;
16513 }
16514
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16515
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16516
16517 612 bgsfx=-1;
16518 612 mainguy=count_enemy=false;
16519 612 deadsfx = WAV_EDEAD;
16520 612 hitsfx = WAV_EHIT;
16521
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16522 612 isCore = false;
16523 612 }
16524
16525 155090 bool esPatraBS::animate(int32_t index)
16526 {
16527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16528
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16529 1552 return Dead(index);
16530
16531 153538 return enemy::animate(index);
16532 155090 }
16533
16534 315868 void esPatraBS::draw(BITMAP *dest)
16535 {
16536 315868 tile=o_tile;
16537
16538
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16539 {
16540
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16541 {
16542 case up: //u
16543 41612 flip=0;
16544 41612 break;
16545
16546 case down: //d
16547 42622 flip=0;
16548 42622 tile+=4;
16549 42622 break;
16550
16551 case left: //l
16552 37916 flip=0;
16553 37916 tile+=8;
16554 37916 break;
16555
16556 case right: //r
16557 38458 flip=0;
16558 38458 tile+=12;
16559 38458 break;
16560
16561 case l_up: //ul
16562 38564 flip=0;
16563 38564 tile+=20;
16564 38564 break;
16565
16566 case r_up: //ur
16567 38568 flip=0;
16568 38568 tile+=24;
16569 38568 break;
16570
16571 case l_down: //dl
16572 38662 flip=0;
16573 38662 tile+=28;
16574 38662 break;
16575
16576 case r_down: //dr
16577 39466 flip=0;
16578 39466 tile+=32;
16579 39466 break;
16580 }
16581
16582 315868 tile += ((clk&6)>>1);
16583 315868 }
16584 else
16585 {
16586 tile += (clk&4)?1:0;
16587 }
16588
16589
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16590 283752 enemy::draw(dest);
16591 315868 }
16592
16593 351473 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16594 {
16595
4/6
✓ Branch 0 taken 242582 times.
✓ Branch 1 taken 108891 times.
✓ Branch 2 taken 242582 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242582 times.
✗ Branch 5 not taken.
351473 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16596
4/8
✓ Branch 0 taken 351473 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 351473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351473 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 351473 times.
✗ Branch 7 not taken.
351473 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16597
1/2
✓ Branch 0 taken 351473 times.
✗ Branch 1 not taken.
351473 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16598 351473 }
16599
16600 77344 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16601 {
16602 // Kludge
16603
4/8
✓ Branch 0 taken 77344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77344 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77344 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 77344 times.
✗ Branch 7 not taken.
77344 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16604 77344 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77344 times.
77344 delete w;
16606 77344 return ret;
16607 }
16608
16609 9565 void enemy_scored(int32_t index)
16610 {
16611 9565 ((enemy*)guys.spr(index))->scored=true;
16612 9565 }
16613
16614 2198 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16615 {
16616
5/8
✓ Branch 0 taken 2198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 286 times.
✓ Branch 5 taken 1912 times.
✓ Branch 6 taken 2198 times.
✗ Branch 7 not taken.
2198 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16617
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 765 times.
2198 if (isdungeon(g->screen_spawned))
16618 765 g->y += 1;
16619
5/6
✓ Branch 0 taken 1284 times.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1280 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2198 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16620 {
16621 4 g->o_tile = parentscr->guytile;
16622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16623 4 g->flags &= ~guy_invisible;
16624 4 g->cs = parentscr->guycs;
16625 4 }
16626 2198 guys.add(g);
16627 2198 }
16628
16629 23828 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16630 {
16631
4/8
✓ Branch 0 taken 23828 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23828 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23828 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23828 times.
✗ Branch 7 not taken.
23828 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16632 23828 items.add(i);
16633 23828 }
16634
16635 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16636 {
16637
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16638 150 items.add(i);
16639 150 }
16640
16641 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16642 {
16643
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16644 3 items.add(i);
16645 3 }
16646
16647 20075 void add_item_for_screen(int32_t screen, item* item)
16648 {
16649 20075 item->screen_spawned = screen;
16650 20075 items.add(item);
16651 20075 }
16652
16653 103 void kill_em_all()
16654 {
16655
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 103 times.
464 for(int32_t i=0; i<guys.Count(); i++)
16656 {
16657 361 enemy *e = ((enemy*)guys.spr(i));
16658
16659
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 331 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
361 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16660
16661 331 e->kickbucket();
16662 331 }
16663 103 }
16664
16665 bool can_kill_em_all()
16666 {
16667 for(int32_t i=0; i<guys.Count(); i++)
16668 {
16669 enemy *e = ((enemy*)guys.spr(i));
16670
16671 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16672 if(e->superman) continue;
16673 return true;
16674 }
16675 return false;
16676 }
16677
16678 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16679 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16680 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16681 {
16682 for(int32_t i=0; i<guys.Count(); i++)
16683 {
16684 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16685 {
16686 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16687 &&(((enemy*)guys.spr(i))->d->type != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16688 {
16689 return i;
16690 }
16691 }
16692 }
16693
16694 return -1;
16695 }
16696
16697 13650379 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16698 {
16699
4/4
✓ Branch 0 taken 16611 times.
✓ Branch 1 taken 13633768 times.
✓ Branch 2 taken 34773736 times.
✓ Branch 3 taken 13618996 times.
48392732 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16700 {
16701
2/2
✓ Branch 0 taken 31383 times.
✓ Branch 1 taken 34742353 times.
34773736 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16702 {
16703 31383 return i;
16704 }
16705 34742353 }
16706
16707 13618996 return -1;
16708 13650379 }
16709
16710 // For Hero's hit detection. Count them if they are dying.
16711 54760 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16712 {
16713 54760 enemy *e = (enemy*)guys.spr(index);
16714
3/4
✓ Branch 0 taken 54760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29580 times.
✓ Branch 3 taken 25180 times.
54760 if(!e || e->hp > 0)
16715 29580 return -1;
16716
16717 25180 bool d = e->dying;
16718 25180 int32_t hc = e->hclk;
16719 25180 e->dying = false;
16720 25180 e->hclk = 0;
16721 25180 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16722 25180 e->dying = d;
16723 25180 e->hclk = hc;
16724
16725
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 25023 times.
25180 return hit ? index : -1;
16726 54760 }
16727
16728 15201317 bool hasMainGuy(int screen)
16729 {
16730
2/2
✓ Branch 0 taken 16384185 times.
✓ Branch 1 taken 6127318 times.
22511503 for(int32_t i=0; i<guys.Count(); i++)
16731 {
16732 16384185 enemy* e = (enemy*)guys.spr(i);
16733
4/4
✓ Branch 0 taken 15921101 times.
✓ Branch 1 taken 463084 times.
✓ Branch 2 taken 9073999 times.
✓ Branch 3 taken 6847102 times.
16384185 if (e->screen_spawned == screen && e->mainguy)
16734 {
16735 9073999 return true;
16736 }
16737 7310186 }
16738
16739 6127318 return false;
16740 15201317 }
16741
16742 143 void EatHero(int32_t index)
16743 {
16744 143 ((eStalfos*)guys.spr(index))->eathero();
16745 143 }
16746
16747 9 void GrabHero(int32_t index)
16748 {
16749 9 ((eWallM*)guys.spr(index))->grabhero();
16750 9 }
16751
16752 1338 bool CarryHero()
16753 {
16754
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
16755 {
16756
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->type==eeWALLM)
16757 {
16758
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
16759 {
16760 1338 Hero.x=guys.spr(i)->x;
16761 1338 Hero.y=guys.spr(i)->y;
16762 1338 return ((eWallM*)guys.spr(i))->misc > 0;
16763 }
16764 505 }
16765
16766 // Like Likes currently can't carry Hero.
16767 /*
16768 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16769 {
16770 if(((eLikeLike*)guys.spr(i))->hashero)
16771 {
16772 Hero.x=guys.spr(i)->x;
16773 Hero.y=guys.spr(i)->y;
16774 return (true);
16775 }
16776 }*/
16777 2595 }
16778
16779 return false;
16780 1338 }
16781
16782 // Move item with guy
16783 void movefairy(zfix &x,zfix &y,int32_t misc)
16784 {
16785 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16786
16787 if(i!=-1)
16788 {
16789 x = guys.spr(i)->x;
16790 y = guys.spr(i)->y;
16791 }
16792 }
16793
16794 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16795 void movefairy2(zfix x,zfix y,int32_t misc)
16796 {
16797 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16798
16799 if(i!=-1)
16800 {
16801 guys.spr(i)->x = x;
16802 guys.spr(i)->y = y;
16803 }
16804 }// Move item with guy
16805
16806 61175 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16807 {
16808 61175 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16809
16810
1/2
✓ Branch 0 taken 61175 times.
✗ Branch 1 not taken.
61175 if(fairy)
16811 {
16812 61175 x = fairy->x;
16813 61175 y = fairy->y;
16814 61175 }
16815 61175 }
16816
16817 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16818 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16819 {
16820 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16821
16822
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16823 {
16824 404 fairy->x = x;
16825 404 fairy->y = y;
16826 404 }
16827 404 }
16828
16829 void killfairy(int32_t misc)
16830 {
16831 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16832 guys.del(i);
16833 }
16834
16835 223 int32_t getGuyIndex(const int32_t eid)
16836 {
16837
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 for(word i = 0; i < guys.Count(); i++)
16838 {
16839
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 623 times.
846 if(guys.spr(i)->getUID() == eid)
16840 223 return i;
16841 623 }
16842
16843 return -1;
16844 223 }
16845
16846 223 void killfairynew(item const &itemfairy)
16847 {
16848 223 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16849
1/2
✓ Branch 0 taken 223 times.
✗ Branch 1 not taken.
223 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16850 223 }
16851
16852 //Should probably change this to return an 'enemy*', null on failure -Em
16853 22077 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16854 {
16855 22077 return addenemy_z(screen,x,y,0,id,clk);
16856 }
16857
16858 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, sprite* parent)
16859 {
16860 1965 return addchild_z(screen,x,y,0,id,clk, parent);
16861 }
16862
16863 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, sprite* parent)
16864 {
16865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16866
16867 1997 int32_t ret = 0;
16868 1997 sprite *e=NULL;
16869
16870
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].type)
16871 {
16872 //Fixme: possible enemy memory leak. (minor)
16873 case eeWALK:
16874
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16875 110 break;
16876
16877 case eeLEV:
16878 e = new eLeever((zfix)x,(zfix)y,id,clk);
16879 break;
16880
16881 case eeTEK:
16882 e = new eTektite((zfix)x,(zfix)y,id,clk);
16883 break;
16884
16885 case eePEAHAT:
16886 e = new ePeahat((zfix)x,(zfix)y,id,clk);
16887 break;
16888
16889 case eeZORA:
16890 e = new eZora((zfix)x,(zfix)y,id,clk);
16891 break;
16892
16893 case eeGHINI:
16894 e = new eGhini((zfix)x,(zfix)y,id,clk);
16895 break;
16896
16897 case eeKEESE:
16898
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
16899 1865 break;
16900
16901 case eeWIZZ:
16902
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
16903 15 break;
16904
16905 case eePROJECTILE:
16906 e = new eProjectile((zfix)x,(zfix)y,id,clk);
16907 break;
16908
16909 case eeWALLM:
16910 e = new eWallM((zfix)x,(zfix)y,id,clk);
16911 break;
16912
16913 case eeAQUA:
16914 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
16915 break;
16916
16917 case eeMOLD:
16918 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
16919 break;
16920
16921 case eeMANHAN:
16922
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
16923 1 break;
16924
16925 case eeGLEEOK:
16926 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
16927 break;
16928
16929 case eeGHOMA:
16930 e = new eGohma((zfix)x,(zfix)y,id,clk);
16931 break;
16932
16933 case eeLANM:
16934 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
16935 break;
16936
16937 case eeGANON:
16938 e = new eGanon((zfix)x,(zfix)y,id,clk);
16939 break;
16940
16941 case eeFAIRY:
16942 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
16943 break;
16944
16945 case eeFIRE:
16946
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
16947 2 break;
16948
16949 case eeOTHER:
16950 e = new eOther((zfix)x,(zfix)y,id,clk);
16951 break;
16952
16953
16954 case eeSCRIPT01:
16955 case eeSCRIPT02:
16956 case eeSCRIPT03:
16957 case eeSCRIPT04:
16958 case eeSCRIPT05:
16959 case eeSCRIPT06:
16960 case eeSCRIPT07:
16961 case eeSCRIPT08:
16962 case eeSCRIPT09:
16963 case eeSCRIPT10:
16964 case eeSCRIPT11:
16965 case eeSCRIPT12:
16966 case eeSCRIPT13:
16967 case eeSCRIPT14:
16968 case eeSCRIPT15:
16969 case eeSCRIPT16:
16970 case eeSCRIPT17:
16971 case eeSCRIPT18:
16972 case eeSCRIPT19:
16973 case eeSCRIPT20:
16974 {
16975 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
16976 {
16977 e = new eScript((zfix)x,(zfix)y,id,clk);
16978 break;
16979 }
16980 else return 0;
16981 }
16982
16983 case eeFFRIENDLY01:
16984 case eeFFRIENDLY02:
16985 case eeFFRIENDLY03:
16986 case eeFFRIENDLY04:
16987 case eeFFRIENDLY05:
16988 case eeFFRIENDLY06:
16989 case eeFFRIENDLY07:
16990 case eeFFRIENDLY08:
16991 case eeFFRIENDLY09:
16992 case eeFFRIENDLY10:
16993 {
16994 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
16995 {
16996 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
16997 }
16998 else return 0;
16999
17000 }
17001
17002 case eeSPINTILE:
17003 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17004 break;
17005
17006 // and these enemies use the misc10/misc2 value
17007 case eeROCK:
17008 {
17009 switch(guysbuf[id&0xFFF].attributes[9])
17010 {
17011 case 1:
17012 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17013 break;
17014
17015 case 0:
17016 default:
17017 e = new eRock((zfix)x,(zfix)y,id,clk);
17018 break;
17019 }
17020
17021 break;
17022 }
17023
17024 case eeTRAP:
17025 {
17026 switch(guysbuf[id&0xFFF].attributes[1])
17027 {
17028 case 1:
17029 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17030 break;
17031
17032 case 0:
17033 default:
17034 e = new eTrap((zfix)x,(zfix)y,id,clk);
17035 break;
17036 }
17037
17038 break;
17039 }
17040
17041 case eeDONGO:
17042 {
17043 switch(guysbuf[id&0xFFF].attributes[9])
17044 {
17045 case 1:
17046 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17047 break;
17048
17049 case 0:
17050 default:
17051 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17052 break;
17053 }
17054
17055 break;
17056 }
17057
17058 case eeDIG:
17059 {
17060
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17061 {
17062 case 1:
17063 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17064 break;
17065
17066 4 case 0:
17067 default:
17068
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17069 4 break;
17070 }
17071
17072 4 break;
17073 }
17074
17075 case eePATRA:
17076 {
17077 switch(guysbuf[id&0xFFF].attributes[9])
17078 {
17079 case 1:
17080 if (get_qr(qr_HARDCODED_BS_PATRA))
17081 {
17082 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17083 break;
17084 }
17085 [[fallthrough]];
17086 case 0:
17087 default:
17088 e = new ePatra((zfix)x,(zfix)y,id,clk);
17089 break;
17090 }
17091
17092 break;
17093 }
17094
17095 case eeGUY:
17096 {
17097 switch(guysbuf[id&0xFFF].attributes[9])
17098 {
17099 case 1:
17100 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17101 break;
17102
17103 case 0:
17104 default:
17105 e = new eNPC((zfix)x,(zfix)y,id,clk);
17106 break;
17107 }
17108
17109 break;
17110 }
17111
17112 case eeNONE:
17113 if(guysbuf[id&0xFFF].attributes[9] ==1)
17114 {
17115 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17116 break;
17117 break;
17118 }
17119 [[fallthrough]];
17120 default:
17121
17122 return 0;
17123 }
17124
17125 1997 ret++; // Made one enemy.
17126
17127
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17128 {
17129 7 e->z = (zfix)z;
17130 7 }
17131
17132
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17133 1997 e->setParent(parent);
17134
17135
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17136 {
17137 return 0;
17138 }
17139
17140 // add segments of segmented enemies
17141 1997 int32_t c=0;
17142
17143
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].type)
17144 {
17145 case eeMOLD:
17146 {
17147 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17148 id &= 0xFFF;
17149
17150 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17151 {
17152 //christ this is messy -DD
17153 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17154
17155 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17156 {
17157 al_trace("Moldorm segment %d could not be created!\n",i+1);
17158
17159 for(int32_t j=0; j<i+1; j++)
17160 guys.del(guys.Count()-1);
17161
17162 return 0;
17163 }
17164
17165 if(i>0)
17166 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17167
17168 ret++;
17169 }
17170
17171 break;
17172 }
17173
17174 case eeLANM:
17175 {
17176 id &= 0xFFF;
17177 int32_t shft = guysbuf[id].attributes[1];
17178 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17179
17180 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17181 {
17182 al_trace("Lanmola segment 1 could not be created!\n");
17183 guys.del(guys.Count()-1);
17184 return 0;
17185 }
17186
17187 ret++;
17188
17189 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17190 {
17191 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17192 {
17193 al_trace("Lanmola segment %d could not be created!\n",i+1);
17194
17195 for(int32_t j=0; j<i+1; j++)
17196 guys.del(guys.Count()-1);
17197
17198 return 0;
17199 }
17200
17201 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17202 ret++;
17203 }
17204 }
17205 break;
17206
17207 case eeMANHAN:
17208 1 id &= 0xFFF;
17209
17210
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17211 {
17212
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17213 {
17214 al_trace("Manhandla head %d could not be created!\n",i+1);
17215
17216 for(int32_t j=0; j<i+1; j++)
17217 {
17218 guys.del(guys.Count()-1);
17219 }
17220
17221 return 0;
17222 }
17223
17224 4 ret++;
17225 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17226 4 }
17227
17228 1 break;
17229
17230 case eeGLEEOK:
17231 {
17232 id &= 0xFFF;
17233
17234 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17235 {
17236 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17237 {
17238 al_trace("Gleeok head %d could not be created!\n",i+1);
17239
17240 for(int32_t j=0; j<i+1; j++)
17241 {
17242 guys.del(guys.Count()-1);
17243 }
17244
17245 return false;
17246 }
17247
17248 c-=guysbuf[id].attributes[3];
17249 ret++;
17250 }
17251 }
17252 break;
17253
17254
17255 case eePATRA:
17256 {
17257 id &= 0xFFF;
17258 int32_t outeyes = 0;
17259
17260 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17261 {
17262 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17263 {
17264 al_trace("Patra outer eye %d could not be created!\n",i+1);
17265
17266 for(int32_t j=0; j<i+1; j++)
17267 guys.del(guys.Count()-1);
17268
17269 return 0;
17270 }
17271 else
17272 outeyes++;
17273
17274 ret++;
17275 }
17276
17277 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17278 {
17279 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17280 {
17281 al_trace("Patra inner eye %d could not be created!\n",i+1);
17282
17283 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17284 guys.del(guys.Count()-1);
17285
17286 return 0;
17287 }
17288
17289 ret++;
17290 }
17291
17292 break;
17293 }
17294 }
17295
17296
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17297 {
17298 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17299 2001 e->screen_spawned = screen;
17300 2001 }
17301
17302 1997 return ret;
17303 1997 }
17304
17305 // Returns number of enemies/segments created
17306 106087 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17307 {
17308 106087 int32_t realid = id&0xFFF;
17309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106087 times.
106087 if( realid > MAXGUYS )
17310 {
17311 return 0;
17312 }
17313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106087 times.
106087 if(id <= 0) return 0;
17314
17315 106087 int32_t ret = 0;
17316 106087 sprite *e=NULL;
17317
17318
29/31
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 52443 times.
✓ Branch 4 taken 4434 times.
✓ Branch 5 taken 5303 times.
✓ Branch 6 taken 1833 times.
✓ Branch 7 taken 2874 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 12541 times.
✓ Branch 10 taken 5335 times.
✓ Branch 11 taken 4433 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 736 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7780 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2573 times.
✓ Branch 26 taken 257 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
106087 switch(guysbuf[id&0xFFF].type)
17319 {
17320 //Fixme: possible enemy memory leak. (minor)
17321 case eeWALK:
17322
3/6
✓ Branch 0 taken 52443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52443 times.
✗ Branch 5 not taken.
52443 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17323 52443 break;
17324
17325 case eeLEV:
17326
3/6
✓ Branch 0 taken 4434 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4434 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4434 times.
✗ Branch 5 not taken.
4434 e = new eLeever((zfix)x,(zfix)y,id,clk);
17327 4434 break;
17328
17329 case eeTEK:
17330
3/6
✓ Branch 0 taken 5303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5303 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5303 times.
✗ Branch 5 not taken.
5303 e = new eTektite((zfix)x,(zfix)y,id,clk);
17331 5303 break;
17332
17333 case eePEAHAT:
17334
3/6
✓ Branch 0 taken 1833 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1833 times.
✗ Branch 5 not taken.
1833 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17335 1833 break;
17336
17337 case eeZORA:
17338
3/6
✓ Branch 0 taken 2874 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2874 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2874 times.
✗ Branch 5 not taken.
2874 e = new eZora((zfix)x,(zfix)y,id,clk);
17339 2874 break;
17340
17341 case eeGHINI:
17342
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17343 461 break;
17344
17345 case eeKEESE:
17346
3/6
✓ Branch 0 taken 12541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12541 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12541 times.
✗ Branch 5 not taken.
12541 e = new eKeese((zfix)x,(zfix)y,id,clk);
17347 12541 break;
17348
17349 case eeWIZZ:
17350
3/6
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5335 times.
✗ Branch 5 not taken.
5335 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17351 5335 break;
17352
17353 case eePROJECTILE:
17354
3/6
✓ Branch 0 taken 4433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4433 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4433 times.
✗ Branch 5 not taken.
4433 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17355 4433 break;
17356
17357 case eeWALLM:
17358
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17359 998 break;
17360
17361 case eeAQUA:
17362
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17363 126 break;
17364
17365 case eeMOLD:
17366
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17367 618 break;
17368
17369 case eeMANHAN:
17370
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17371 149 break;
17372
17373 case eeGLEEOK:
17374
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17375 168 break;
17376
17377 case eeGHOMA:
17378
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17379 93 break;
17380
17381 case eeLANM:
17382
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17383 420 break;
17384
17385 case eeGANON:
17386
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17387 13 break;
17388
17389 case eeFAIRY:
17390
3/6
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 736 times.
✗ Branch 5 not taken.
736 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17391 736 break;
17392
17393 case eeFIRE:
17394
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17395 758 break;
17396
17397 case eeOTHER:
17398
3/6
✓ Branch 0 taken 7780 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7780 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7780 times.
✗ Branch 5 not taken.
7780 e = new eOther((zfix)x,(zfix)y,id,clk);
17399 7780 break;
17400
17401
17402 case eeSCRIPT01:
17403 case eeSCRIPT02:
17404 case eeSCRIPT03:
17405 case eeSCRIPT04:
17406 case eeSCRIPT05:
17407 case eeSCRIPT06:
17408 case eeSCRIPT07:
17409 case eeSCRIPT08:
17410 case eeSCRIPT09:
17411 case eeSCRIPT10:
17412 case eeSCRIPT11:
17413 case eeSCRIPT12:
17414 case eeSCRIPT13:
17415 case eeSCRIPT14:
17416 case eeSCRIPT15:
17417 case eeSCRIPT16:
17418 case eeSCRIPT17:
17419 case eeSCRIPT18:
17420 case eeSCRIPT19:
17421 case eeSCRIPT20:
17422 {
17423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17424 {
17425
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eScript((zfix)x,(zfix)y,id,clk);
17426 30 break;
17427 }
17428 else return 0;
17429 }
17430
17431 case eeFFRIENDLY01:
17432 case eeFFRIENDLY02:
17433 case eeFFRIENDLY03:
17434 case eeFFRIENDLY04:
17435 case eeFFRIENDLY05:
17436 case eeFFRIENDLY06:
17437 case eeFFRIENDLY07:
17438 case eeFFRIENDLY08:
17439 case eeFFRIENDLY09:
17440 case eeFFRIENDLY10:
17441 {
17442 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17443 {
17444 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17445 }
17446 else return 0;
17447
17448 }
17449
17450 case eeSPINTILE:
17451
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17452 94 break;
17453
17454 // and these enemies use the misc10/misc2 value
17455 case eeROCK:
17456 {
17457
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17458 {
17459 case 1:
17460
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17461 30 break;
17462
17463 354 case 0:
17464 default:
17465
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17466 354 break;
17467 }
17468
17469 384 break;
17470 }
17471
17472 case eeTRAP:
17473 {
17474
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✓ Branch 2 taken 1680 times.
2573 switch(guysbuf[id&0xFFF].attributes[1])
17475 {
17476 case 1:
17477
3/6
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 893 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 893 times.
✗ Branch 5 not taken.
893 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17478 893 break;
17479
17480 1680 case 0:
17481 default:
17482
3/6
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1680 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1680 times.
✗ Branch 5 not taken.
1680 e = new eTrap((zfix)x,(zfix)y,id,clk);
17483 1680 break;
17484 }
17485
17486 2573 break;
17487 }
17488
17489 case eeDONGO:
17490 {
17491
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 209 times.
257 switch(guysbuf[id&0xFFF].attributes[9])
17492 {
17493 case 1:
17494
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17495 48 break;
17496
17497 209 case 0:
17498 default:
17499
3/6
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 209 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 209 times.
✗ Branch 5 not taken.
209 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17500 209 break;
17501 }
17502
17503 257 break;
17504 }
17505
17506 case eeDIG:
17507 {
17508
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17509 {
17510 case 1:
17511
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17512 327 break;
17513
17514 76 case 0:
17515 default:
17516
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17517 76 break;
17518 }
17519
17520 403 break;
17521 }
17522
17523 case eePATRA:
17524 {
17525
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17526 {
17527 case 1:
17528
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17529 {
17530
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17531 102 break;
17532 }
17533 [[fallthrough]];
17534 190 case 0:
17535 default:
17536
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17537 190 break;
17538 }
17539
17540 292 break;
17541 }
17542
17543 case eeGUY:
17544 {
17545
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17546 {
17547 case 1:
17548 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17549 break;
17550
17551 5 case 0:
17552 default:
17553
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17554 5 break;
17555 }
17556
17557 5 break;
17558 }
17559
17560 case eeNONE:
17561
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17562 {
17563
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17564 533 break;
17565 }
17566 [[fallthrough]];
17567 default:
17568
17569 return 0;
17570 }
17571
17572 106087 ret++; // Made one enemy.
17573
17574
4/4
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 105809 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 232 times.
106087 if(z && canfall(id))
17575 {
17576 232 e->z = (zfix)z;
17577 232 }
17578
17579
2/2
✓ Branch 0 taken 105809 times.
✓ Branch 1 taken 278 times.
106087 ((enemy*)e)->ceiling = (z && canfall(id));
17580
17581
1/2
✓ Branch 0 taken 106087 times.
✗ Branch 1 not taken.
106087 if(!guys.add(e))
17582 {
17583 return 0;
17584 }
17585
17586 // add segments of segmented enemies
17587 106087 int32_t c=0;
17588
17589
6/6
✓ Branch 0 taken 104440 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
106087 switch(guysbuf[id&0xFFF].type)
17590 {
17591 case eeMOLD:
17592 {
17593 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17594 618 id &= 0xFFF;
17595
17596
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17597 {
17598 //christ this is messy -DD
17599 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17600
17601
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17602 {
17603 al_trace("Moldorm segment %d could not be created!\n",i+1);
17604
17605 for(int32_t j=0; j<i+1; j++)
17606 guys.del(guys.Count()-1);
17607
17608 return 0;
17609 }
17610
17611
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17612 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17613
17614 3150 ret++;
17615 3150 }
17616
17617 618 break;
17618 }
17619
17620 case eeLANM:
17621 {
17622 420 id &= 0xFFF;
17623 420 int32_t shft = guysbuf[id].attributes[1];
17624 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17625
17626
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17627 {
17628 al_trace("Lanmola segment 1 could not be created!\n");
17629 guys.del(guys.Count()-1);
17630 return 0;
17631 }
17632
17633 420 ret++;
17634
17635
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17636 {
17637
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17638 {
17639 al_trace("Lanmola segment %d could not be created!\n",i+1);
17640
17641 for(int32_t j=0; j<i+1; j++)
17642 guys.del(guys.Count()-1);
17643
17644 return 0;
17645 }
17646
17647 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17648 1847 ret++;
17649 1847 }
17650 }
17651 420 break;
17652
17653 case eeMANHAN:
17654 149 id &= 0xFFF;
17655
17656
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17657 {
17658
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17659 {
17660 al_trace("Manhandla head %d could not be created!\n",i+1);
17661
17662 for(int32_t j=0; j<i+1; j++)
17663 {
17664 guys.del(guys.Count()-1);
17665 }
17666
17667 return 0;
17668 }
17669
17670 688 ret++;
17671 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17672 688 }
17673
17674 149 break;
17675
17676 case eeGLEEOK:
17677 {
17678 168 id &= 0xFFF;
17679 168 eGleeok* parent = (eGleeok*)e;
17680
17681
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17682 {
17683
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17684
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
17685 {
17686 al_trace("Gleeok head %d could not be created!\n",i+1);
17687
17688 for(int32_t j=0; j<i+1; j++)
17689 {
17690 guys.del(guys.Count()-1);
17691 }
17692
17693 return false;
17694 }
17695
17696 533 head->necktile=parent->necktile;
17697 533 head->dummy_int[1]=parent->necktile;
17698
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
17699 {
17700 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17701 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17702 421 }
17703 else
17704 {
17705 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17706 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17707 }
17708 533 head->tile = head->dummy_int[2];
17709
17710 533 c-=guysbuf[id].attributes[3];
17711 533 ret++;
17712 533 }
17713 }
17714 168 break;
17715
17716
17717 case eePATRA:
17718 {
17719 292 id &= 0xFFF;
17720 292 int32_t outeyes = 0;
17721
17722
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17723 {
17724
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17725 {
17726 al_trace("Patra outer eye %d could not be created!\n",i+1);
17727
17728 for(int32_t j=0; j<i+1; j++)
17729 guys.del(guys.Count()-1);
17730
17731 return 0;
17732 }
17733 else
17734 1956 outeyes++;
17735
17736 1956 ret++;
17737 1956 }
17738
17739
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17740 {
17741
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17742 {
17743 al_trace("Patra inner eye %d could not be created!\n",i+1);
17744
17745 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17746 guys.del(guys.Count()-1);
17747
17748 return 0;
17749 }
17750
17751 312 ret++;
17752 312 }
17753
17754 292 break;
17755 }
17756 }
17757
17758
2/2
✓ Branch 0 taken 114993 times.
✓ Branch 1 taken 106087 times.
221080 for (int i = 0; i < ret; i++)
17759 {
17760 114993 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17761 114993 e->screen_spawned = screen;
17762 114993 }
17763
17764 106087 return ret;
17765 106087 }
17766
17767 2069977 bool isjumper(int32_t id)
17768 {
17769
2/4
✓ Branch 0 taken 2069977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2069977 times.
2069977 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17770 {
17771 return false;
17772 }
17773
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1963949 times.
✓ Branch 2 taken 106019 times.
2069977 switch(guysbuf[id&0xFFF].type)
17774 {
17775 case eeROCK:
17776 case eeTEK:
17777 9 return true;
17778
17779 case eeWALK:
17780
3/4
✓ Branch 0 taken 106019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93754 times.
106019 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17781 93754 }
17782
17783 2057703 return false;
17784 2069977 }
17785
17786
17787 8068 bool isfixedtogrid(int32_t id)
17788 {
17789
2/4
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8068 times.
8068 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17790 {
17791 return false;
17792 }
17793
1/2
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
8068 switch(guysbuf[id&0xFFF].type)
17794 {
17795 case eeWALK:
17796 case eeLEV:
17797 case eeZORA:
17798 case eeDONGO:
17799 case eeGANON:
17800 case eeROCK:
17801 case eeGLEEOK:
17802 case eeAQUA:
17803 case eeLANM:
17804 return true;
17805 }
17806
17807 8068 return false;
17808 8068 }
17809
17810 // Can't fall, can have Z value.
17811 78266434 bool isflier(int32_t id)
17812 {
17813
3/4
✓ Branch 0 taken 78266434 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110858 times.
✓ Branch 3 taken 78155576 times.
78266434 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17814 {
17815 110858 return false;
17816 }
17817
2/2
✓ Branch 0 taken 14392561 times.
✓ Branch 1 taken 63763015 times.
78155576 switch(guysbuf[id&0xFFF].type) //id&0x0FFF)
17818 {
17819 case eePEAHAT:
17820 case eeKEESE:
17821 case eePATRA:
17822 case eeFAIRY:
17823 case eeGHINI:
17824
17825 // Could theoretically have their Z set by a script
17826 case eeFIRE:
17827 14392561 return true;
17828 break;
17829 }
17830
17831 63763015 return false;
17832 78266434 }
17833
17834 // Can't have Z position
17835 4056840 bool never_in_air(int32_t id)
17836 {
17837
2/4
✓ Branch 0 taken 4056840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4056840 times.
4056840 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17838 {
17839 return false;
17840 }
17841
2/2
✓ Branch 0 taken 4047248 times.
✓ Branch 1 taken 9592 times.
4056840 switch(guysbuf[id&0xFFF].type)
17842 {
17843 case eeMANHAN:
17844 case eeMOLD:
17845 case eeLANM:
17846 case eeGLEEOK:
17847 case eeZORA:
17848 case eeLEV:
17849 case eeAQUA:
17850 case eeROCK:
17851 case eeGANON:
17852 case eeTRAP:
17853 case eePROJECTILE:
17854 case eeSPINTILE:
17855 9592 return true;
17856 }
17857
17858 4047248 return false;
17859 4056840 }
17860
17861 2258945 bool canfall(int32_t id)
17862 {
17863
3/4
✓ Branch 0 taken 2258945 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 2258899 times.
2258945 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17864 {
17865 46 return false;
17866 }
17867
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2258859 times.
✓ Branch 2 taken 40 times.
2258899 switch(guysbuf[id&0xFFF].type)
17868 {
17869 case eeGUY:
17870 {
17871
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17872 40 return false;
17873
17874 switch(guysbuf[id&0xFFF].attributes[9])
17875 {
17876 case 1:
17877 case 2:
17878 return true;
17879
17880 case 0:
17881 case 3:
17882 default:
17883 return false;
17884 }
17885
17886 case eeGHOMA:
17887 case eeDIG:
17888 return false;
17889 }
17890 }
17891
17892
17893
4/4
✓ Branch 0 taken 2250381 times.
✓ Branch 1 taken 8478 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2069977 times.
2258859 return !never_in_air(id) && !isflier(id) && !isjumper(id);
17894 2258945 }
17895
17896 60437751 bool enemy::enemycanfall(int32_t id, bool checkgrav) const
17897 {
17898
3/4
✓ Branch 0 taken 60437751 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89598 times.
✓ Branch 3 taken 60348153 times.
60437751 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17899 {
17900 89598 return false;
17901 }
17902 //Z_scripterrlog("canfall family is %d:\n", family);
17903 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
17904 //if ( family == eeFIRE && id >= eSTART )
17905 //{
17906 // Z_scripterrlog("eeFire\n");
17907 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
17908 //}
17909
17910 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
17911
17912
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 57841741 times.
✓ Branch 2 taken 2077477 times.
60348153 switch(guysbuf[id&0xFFF].type)
17913 {
17914 case eeGUY:
17915 {
17916
1/2
✓ Branch 0 taken 2077477 times.
✗ Branch 1 not taken.
2077477 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
17917 2077477 return false;
17918
17919 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
17920 {
17921 case 1:
17922 case 2:
17923 return true;
17924
17925 case 0:
17926 case 3:
17927 default:
17928 return false;
17929 }
17930
17931 case eeGHOMA:
17932 case eeDIG:
17933 428935 return false;
17934 }
17935 }
17936
17937
2/2
✓ Branch 0 taken 40224377 times.
✓ Branch 1 taken 17617364 times.
57841741 if(!checkgrav) return true;
17938 40224377 return (moveflags & move_obeys_grav);
17939
17940 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
17941 // {
17942 // if ( moveflags & move_obeys_grav ) return true;
17943 // else return false;
17944 // }
17945 // else
17946 // {
17947 // return (moveflags & move_obeys_grav);
17948 // }
17949 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
17950 60437751 }
17951
17952 1278 void addfires()
17953 {
17954
2/2
✓ Branch 0 taken 821 times.
✓ Branch 1 taken 457 times.
1278 if(!get_qr(qr_NOGUYFIRES))
17955 {
17956 2285 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
17957 457 int32_t bs = get_qr(qr_BSZELDA);
17958 914 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
17959 914 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
17960 457 }
17961 1278 }
17962
17963 // This function runs one time for every screen on the first frame of a region being loaded.
17964 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
17965 38706 static void loadguys(mapscr* scr)
17966 {
17967 38706 int screen = scr->screen;
17968 38706 byte Guy=0;
17969 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
17970 // Else use mITEM and ipONETIME
17971 38706 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
17972 38706 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
17973
17974 38706 mapscr* guyscr = scr;
17975
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 37800 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 431 times.
38706 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
17976 {
17977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(DMaps[cur_dmap].flags&dmfCAVES)
17978 {
17979 431 Guy=special_warp_return_scr->guy;
17980 431 guyscr = special_warp_return_scr;
17981 431 }
17982 431 }
17983 else
17984 {
17985 38275 Guy=scr->guy;
17986
2/2
✓ Branch 0 taken 1669 times.
✓ Branch 1 taken 36606 times.
38275 if (game->get_regionmapping() == REGION_MAPPING_FULL)
17987 36606 mark_visited(screen);
17988 }
17989
17990 119048 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
17991
17992 38706 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
17993 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
17994
4/4
✓ Branch 0 taken 3872 times.
✓ Branch 1 taken 34834 times.
✓ Branch 2 taken 2550 times.
✓ Branch 3 taken 1322 times.
38706 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
17995 {
17996
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1311 times.
1322 if(scr->room==rZELDA)
17997 {
17998 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
17999 11 guys.spr(0)->hxofs=1000;
18000 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18001 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18002 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18003 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18004 11 return;
18005 }
18006
18007
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 11 times.
2611 bool ffire = oldguy
18008
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 29 times.
1300 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18009 11 : (guyscr->roomflags&RFL_GUYFIRES);
18010
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1278 times.
1311 if(ffire)
18011 1278 addfires();
18012
18013
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 425 times.
1311 if(screen>=128)
18014
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
438 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18015 13 Guy=0;
18016
18017
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1098 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1311 switch(scr->room)
18018 {
18019 case rSP_ITEM:
18020 case rGRUMBLE:
18021 case rBOMBS:
18022 case rARROWS:
18023 case rSWINDLE:
18024 case rMUPGRADE:
18025 case rLEARNSLASH:
18026 case rTAKEONE:
18027
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 61 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 61 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18028 55 Guy=0;
18029
18030 179 break;
18031
18032 case rREPAIR:
18033 if (get_qr(qr_OLD_DOORREPAIR)) break;
18034 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18035 Guy=0;
18036
18037 break;
18038 case rRP_HC:
18039 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18040 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18041 Guy=0;
18042
18043 break;
18044 case rMONEY:
18045
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18046 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18047 Guy=0;
18048
18049 break;
18050
18051 case rTRIFORCE:
18052 {
18053 45 int32_t tc = TriforceCount();
18054
18055
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18056 {
18057
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18058 10 Guy=0;
18059 9 }
18060 else
18061 {
18062
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18063 33 Guy=0;
18064 }
18065 }
18066 43 break;
18067 }
18068
18069
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1202 times.
1309 if(Guy)
18070 {
18071
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1169 times.
1202 if(ffire)
18072 1169 blockpath=true;
18073
18074
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 790 times.
1202 if(screen<128)
18075 790 sfx(WAV_SCALE);
18076
18077
6/6
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 728 times.
✓ Branch 4 taken 117 times.
✓ Branch 5 taken 357 times.
2404 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18078 1202 Hero.Freeze();
18079 1202 }
18080 1309 }
18081
5/6
✓ Branch 0 taken 33910 times.
✓ Branch 1 taken 3474 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33839 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3474 times.
37384 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18082 {
18083 71 sfx(WAV_SCALE);
18084 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18085 71 }
18086
18087 116079 loaditem(scr, dx, dy);
18088
18089 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18090 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18091
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 38674 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
38693 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18092 {
18093
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18094 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18095 15 }
18096 38704 }
18097
18098 37462 void loadguys()
18099 {
18100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37462 times.
37462 if (loaded_guys)
18101 return;
18102
18103 37462 loaded_guys = true;
18104 37462 repaircharge = 0;
18105 37462 adjustmagic = false;
18106 37462 learnslash = false;
18107
2/2
✓ Branch 0 taken 112386 times.
✓ Branch 1 taken 37462 times.
149848 for (int32_t i=0; i<3; i++)
18108 {
18109 112386 prices[i] = 0;
18110 112386 }
18111
18112 76168 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18113 38706 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18114 38706 loadguys(scr);
18115 38706 });
18116 37462 }
18117
18118 38712 void loaditem(mapscr* scr, int offx, int offy)
18119 {
18120 38712 int screen = scr->screen;
18121 38712 byte Item = 0;
18122
18123
2/2
✓ Branch 0 taken 37806 times.
✓ Branch 1 taken 906 times.
38712 if(screen<128)
18124 {
18125 37806 Item=scr->item;
18126
18127
4/4
✓ Branch 0 taken 1730 times.
✓ Branch 1 taken 36076 times.
✓ Branch 2 taken 34310 times.
✓ Branch 3 taken 3496 times.
37806 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18128 {
18129
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 3410 times.
3496 if(scr->flags8&fSECRETITEM)
18130 86 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18131
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 2136 times.
3410 else if(scr->flags&fITEM)
18132 1274 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18133
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 2020 times.
2136 else if(scr->flags11&efCARRYITEM)
18134 116 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18135 else
18136 {
18137 2020 int x = scr->itemx;
18138
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2005 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
2020 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18139 -170 :
18140 2020 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18141
3/6
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2020 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2020 times.
✗ Branch 5 not taken.
4040 add_item_for_screen(screen, new item(offx + x, offy + y,
18142
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2005 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2005 times.
✗ Branch 9 not taken.
2020 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18143
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 1908 times.
2020 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].type==itype_triforcepiece ||
18144 2020 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18145 }
18146 3496 }
18147 37806 }
18148
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 475 times.
906 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18149 {
18150
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18151
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18152 {
18153 163 Item = special_warp_return_scr->catchall;
18154
18155
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18156 {
18157 162 int x = scr->itemx;
18158
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18159 -170 :
18160 162 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18161
3/6
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
324 add_item_for_screen(screen, new item(offx + x, offy + y,
18162
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18163 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18164 162 }
18165 163 }
18166 475 }
18167 38712 }
18168
18169 957 void never_return(int32_t screen, int32_t index)
18170 {
18171
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18172 191 goto doit;
18173
18174
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18175
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18176 {
18177 437 goto dontdoit;
18178 329 }
18179
18180 doit:
18181 520 setmapflag(get_scr(screen), mNEVERRET);
18182 dontdoit:
18183 957 return;
18184 }
18185
18186 67200 bool slowguy(int32_t id)
18187 {
18188
2/4
✓ Branch 0 taken 67200 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67200 times.
67200 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18189 {
18190 return false;
18191 }
18192
18193 67200 id = id&0xFFF;
18194
18195
2/2
✓ Branch 0 taken 56866 times.
✓ Branch 1 taken 10334 times.
67200 switch(id)
18196 {
18197 case eOCTO1S:
18198 case eOCTO2S:
18199 case eOCTO1F:
18200 case eOCTO2F:
18201 case eLEV1:
18202 case eLEV2:
18203 case eROCK:
18204 case eBOULDER:
18205 10334 return true;
18206 }
18207
18208 56866 return false;
18209 67200 }
18210
18211 87075 static bool ok2add(mapscr* scr, int32_t id)
18212 {
18213
2/4
✓ Branch 0 taken 87075 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 87075 times.
87075 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18214 {
18215 return false;
18216 }
18217
18218 87075 id = id&0xFFF;
18219
18220
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 86246 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
87075 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18221 464 return false;
18222
18223
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 85966 times.
✓ Branch 2 taken 380 times.
✓ Branch 3 taken 201 times.
86611 switch(guysbuf[id].type)
18224 {
18225 // I added a special case for shooters because having traps on the same screen
18226 // was preventing them from spawning due to TMPNORET. This means they will
18227 // never stay dead, though, so it may not be the best solution. - Saf
18228 case eePROJECTILE:
18229 380 return true;
18230
18231
18232 case eeDIG:
18233 {
18234
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18235 {
18236 case 1:
18237
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18238 79 return !getmapflag(scr, mTMPNORET);
18239
18240 47 return true;
18241
18242 75 case 0:
18243 default:
18244 75 return true;
18245 }
18246 }
18247 case eeGANON:
18248 case eeTRAP:
18249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].type == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18250
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].type == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18251 [[fallthrough]];
18252 default:
18253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85966 times.
85966 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18254 85966 break;
18255 }
18256
18257
2/2
✓ Branch 0 taken 20978 times.
✓ Branch 1 taken 64988 times.
85966 if(!get_qr(qr_NOTMPNORET))
18258 64988 return !getmapflag(scr, mTMPNORET);
18259
18260 20978 return true;
18261 87075 }
18262
18263 1668715 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18264 {
18265
3/4
✓ Branch 0 taken 289021 times.
✓ Branch 1 taken 1379694 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 289021 times.
1668715 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18266 {
18267 1379694 return;
18268 }
18269
18270 289021 int32_t ctype = rpos_handle.ctype();
18271
6/6
✓ Branch 0 taken 287513 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 286198 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1213 times.
✓ Branch 5 taken 284985 times.
289021 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18272
18273 12108 auto [x, y] = rpos_handle.xy();
18274
18275 4036 int32_t cx=-1000, cy=-1000;
18276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(!isfixedtogrid(statueID))
18277 {
18278
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2528 times.
4036 if(ctype==cL_STATUE)
18279 {
18280 1508 cx=x+4;
18281 1508 cy=y+7;
18282 1508 }
18283
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1213 times.
2528 else if(ctype==cR_STATUE)
18284 {
18285 1315 cx=x-8;
18286 1315 cy=y-1;
18287 1315 }
18288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 else if(ctype==cC_STATUE)
18289 {
18290 1213 cx=x;
18291 1213 cy=y;
18292 1213 }
18293 4036 }
18294 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18295 {
18296 cx=x;
18297 cy=y;
18298 }
18299
18300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(cx!=-1000) // No point creating it if this is false
18301 {
18302
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18303 {
18304
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18305 {
18306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18307 4 return; // No point deleting it. A script might be toying with it in some way.
18308 else
18309 guys.del(j);
18310 }
18311 9750 }
18312
18313 4032 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18314 4032 }
18315 1668715 }
18316
18317 35997 static void activate_fireball_statues(mapscr* scr)
18318 {
18319
2/2
✓ Branch 0 taken 34577 times.
✓ Branch 1 taken 1420 times.
35997 if (!(scr->flags11&efFIREBALLS))
18320 {
18321 34577 return;
18322 }
18323
18324 251340 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18325 249920 activate_fireball_statue(rpos_handle);
18326 249920 });
18327 35997 }
18328
18329 36680 void load_default_enemies(mapscr* scr)
18330 {
18331 36680 int screen = scr->screen;
18332 42145 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18333
18334 36680 wallm_load_clk=frame-80;
18335
18336
2/2
✓ Branch 0 taken 34784 times.
✓ Branch 1 taken 1896 times.
36680 if(scr->flags11&efZORA)
18337 {
18338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if(zoraID>=0)
18339 5688 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18340 1896 }
18341
18342
2/2
✓ Branch 0 taken 36502 times.
✓ Branch 1 taken 178 times.
36680 if(scr->flags11&efTRAP4)
18343 {
18344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18345 {
18346 534 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18347 534 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18348 534 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18349 534 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18350 178 }
18351 178 }
18352
18353 6492360 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18354 6455680 int32_t ctype = rpos_handle.ctype();
18355 6455680 int32_t cflag = rpos_handle.sflag();
18356 6455680 int32_t cflag_i = rpos_handle.cflag();
18357
18358
4/6
✓ Branch 0 taken 6455680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6455310 times.
✓ Branch 3 taken 370 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6455310 times.
6455680 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18359 {
18360 370 auto [x, y] = rpos_handle.xy();
18361
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 360 times.
370 if(trapLOSHorizontalID>=0)
18362 1080 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18363 370 }
18364
4/6
✓ Branch 0 taken 6455310 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6455088 times.
✓ Branch 3 taken 222 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6455088 times.
6455310 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18365 {
18366 222 auto [x, y] = rpos_handle.xy();
18367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222 times.
222 if(trapLOSVerticalID>=0)
18368 666 addenemy(screen, x, y, trapLOSVerticalID, -14);
18369 222 }
18370
4/6
✓ Branch 0 taken 6455088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6454810 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6454810 times.
6455088 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18371 {
18372 278 auto [x, y] = rpos_handle.xy();
18373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18374 {
18375
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18376 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18377 278 }
18378 278 }
18379
4/6
✓ Branch 0 taken 6454810 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6454374 times.
✓ Branch 3 taken 436 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6454374 times.
6454810 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18380 {
18381 436 auto [x, y] = rpos_handle.xy();
18382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(trapConstantHorizontalID>=0)
18383 1308 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18384 436 }
18385
4/6
✓ Branch 0 taken 6454374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6453917 times.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6453917 times.
6454374 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18386 {
18387 457 auto [x, y] = rpos_handle.xy();
18388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457 times.
457 if(trapConstantVerticalID>=0)
18389 1371 addenemy(screen, x, y, trapConstantVerticalID, -14);
18390 457 }
18391
18392
1/2
✓ Branch 0 taken 6455680 times.
✗ Branch 1 not taken.
6455680 if(ctype==cSPINTILE1)
18393 {
18394 awaken_spinning_tile(rpos_handle);
18395 }
18396 6455680 });
18397
18398
2/2
✓ Branch 0 taken 36624 times.
✓ Branch 1 taken 56 times.
36680 if(scr->flags11&efTRAP2)
18399 {
18400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18401 {
18402
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 64, 80, centerTrapID, -14))
18403 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18404
18405
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 176, 80, centerTrapID, -14))
18406 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18407 56 }
18408 56 }
18409
18410
2/2
✓ Branch 0 taken 36597 times.
✓ Branch 1 taken 83 times.
36680 if(scr->flags11&efROCKS)
18411 {
18412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18413 {
18414 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18415 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18416 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18417 83 }
18418 83 }
18419 36680 }
18420
18421 #define SLOPE_STAGE_COMBOS 0
18422 #define SLOPE_STAGE_FFCS 1
18423 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18424
18425 22842489 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18426 {
18427
2/2
✓ Branch 0 taken 4658462 times.
✓ Branch 1 taken 18184027 times.
22842489 if (stage == SLOPE_STAGE_COMBOS)
18428 18184027 return (region_num_rpos*arg1)+arg2;
18429
2/2
✓ Branch 0 taken 4517266 times.
✓ Branch 1 taken 141196 times.
4658462 if (stage == SLOPE_STAGE_FFCS)
18430 4517266 return (region_num_rpos*7)+arg1;
18431
1/2
✓ Branch 0 taken 141196 times.
✗ Branch 1 not taken.
141196 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18432 141196 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18433 // TODO: what about FFCs from bordering screens?
18434
18435 assert(false);
18436 return 0;
18437 22842489 }
18438
18439 18184027 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18440 {
18441 18184027 mapscr* s = rpos_handle.scr;
18442 18184027 auto& cmb = rpos_handle.combo();
18443
18444 18184027 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18445 18184027 auto it = slopes.find(id);
18446
18447 18184027 bool wasSlope = it!=slopes.end();
18448 18184027 bool isSlope = cmb.type == cSLOPE;
18449
18450
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 18183891 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
18184027 if(isSlope && !wasSlope)
18451 {
18452 272 auto [x, y] = rpos_handle.xy();
18453 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18454 136 }
18455
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18183891 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18183891 else if(wasSlope && !isSlope)
18456 {
18457 slopes.erase(it);
18458 }
18459 18184027 }
18460
18461 141196 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18462 {
18463 141196 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18464 141196 auto it = slopes.find(id);
18465
18466 141196 bool wasSlope = it!=slopes.end();
18467 141196 bool isSlope = is_slope;
18468
18469
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141196 if(isSlope && !wasSlope)
18470 {
18471 static std::vector<word> TMP;
18472 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18473 TMP.resize(num_border_combos * 7 * 4);
18474
18475 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18476 TMP[tmp_index] = cid;
18477 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18478 }
18479
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
141196 else if(wasSlope && !isSlope)
18480 {
18481 slopes.erase(it);
18482 }
18483 141196 }
18484
18485 // Load a single column or row from a nearby screen, and load its slopes.
18486 3884 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18487 {
18488 55866 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18489
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 171 times.
3884 if (map == -1)
18490 171 return;
18491
18492 3713 int offx = 0;
18493 3713 int offy = 0;
18494
2/2
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 913 times.
3713 if (dir == up)
18495 913 offy = -16;
18496
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 1938 times.
2800 else if (dir == down)
18497 862 offy = world_h;
18498
2/2
✓ Branch 0 taken 968 times.
✓ Branch 1 taken 970 times.
1938 else if (dir == left)
18499 968 offx = -16;
18500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 else if (dir == right)
18501 970 offx = world_w;
18502
18503
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 25991 times.
29704 for (int layer = 0; layer < 7; layer++)
18504 {
18505 51982 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18506
2/2
✓ Branch 0 taken 10526 times.
✓ Branch 1 taken 15465 times.
25991 if (!scr) continue;
18507
18508 10526 int slope_count = layer * (16*2);
18509
18510
4/4
✓ Branch 0 taken 7826 times.
✓ Branch 1 taken 2700 times.
✓ Branch 2 taken 2744 times.
✓ Branch 3 taken 5082 times.
10526 if (dir == left || dir == right)
18511 {
18512 5444 int x = dir == left ? 15 : 0;
18513
2/2
✓ Branch 0 taken 59884 times.
✓ Branch 1 taken 5444 times.
65328 for (int y = 0; y < 11; y++)
18514 {
18515 59884 int pos = y * 16 + x;
18516 59884 int cid = scr->data[pos];
18517 59884 bool is_slope = combobuf[cid].type == cSLOPE;
18518
1/2
✓ Branch 0 taken 59884 times.
✗ Branch 1 not taken.
59884 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18519 59884 }
18520 5444 }
18521
3/4
✓ Branch 0 taken 2437 times.
✓ Branch 1 taken 2645 times.
✓ Branch 2 taken 2437 times.
✗ Branch 3 not taken.
5082 else if (dir == up || dir == down)
18522 {
18523 5082 int y = dir == up ? 10 : 0;
18524
2/2
✓ Branch 0 taken 81312 times.
✓ Branch 1 taken 5082 times.
86394 for (int x = 0; x < 16; x++)
18525 {
18526 81312 int pos = y * 16 + x;
18527 81312 int cid = scr->data[pos];
18528 81312 bool is_slope = combobuf[cid].type == cSLOPE;
18529
1/2
✓ Branch 0 taken 81312 times.
✗ Branch 1 not taken.
81312 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18530 81312 }
18531 5082 }
18532
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15465 times.
✓ Branch 2 taken 10526 times.
25991 }
18533 3884 }
18534
18535 37536 void update_slope_comboposes()
18536 {
18537 16802768 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18538 16765232 update_slope_combopos(rpos_handle);
18539 16765232 });
18540
18541
2/2
✓ Branch 0 taken 36565 times.
✓ Branch 1 taken 971 times.
37536 if (Hero.sideview_mode())
18542 {
18543 1942 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18544
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 971 times.
4855 for (int dir = up; dir <= right; dir++)
18545 3884 handle_slope_combopos_bordering_screen(scr->screen, dir);
18546 971 });
18547 971 }
18548
18549 37536 update_slopes();
18550 37536 }
18551
18552 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18553 1418795 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18554 {
18555 1418795 delete_fireball_shooter(rpos_handle);
18556 1418795 }
18557
18558 //Placeholder in case we need it.
18559 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18560 {
18561 return;
18562 }
18563
18564 // Everything that must be done after we change a screen's combo to another combo. -L
18565 1418795 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18566 {
18567
2/2
✓ Branch 0 taken 1418640 times.
✓ Branch 1 taken 155 times.
1418795 if (!(rpos_handle.scr->valid & mVALID))
18568 {
18569 155 rpos_handle.scr->valid |= mVALID;
18570 155 mark_current_region_handles_dirty(); // a new layer becoming valid needs to reload the region handles
18571 155 }
18572 1418795 activate_fireball_statue(rpos_handle);
18573
18574
2/2
✓ Branch 0 taken 1418701 times.
✓ Branch 1 taken 94 times.
1418795 if(rpos_handle.ctype()==cSPINTILE1)
18575 {
18576 94 awaken_spinning_tile(rpos_handle);
18577 94 }
18578
18579 1418795 update_slope_combopos(rpos_handle);
18580 1418795 }
18581
18582 4517266 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18583 {
18584 4517266 ffcdata* ff = ffc_handle.ffc;
18585 4517266 auto& cmb = ffc_handle.combo();
18586
18587 4517266 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18588 4517266 auto it = slopes.find(id);
18589
18590 4517266 bool wasSlope = it!=slopes.end();
18591
1/2
✓ Branch 0 taken 4517266 times.
✗ Branch 1 not taken.
4517266 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18592
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4517266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4517266 if(isSlope && !wasSlope)
18593 {
18594 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18595 }
18596
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4517266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4517266 else if(wasSlope && !isSlope)
18597 {
18598 slopes.erase(it);
18599 }
18600
18601 4517266 ffc_handle.scr->ffcCountMarkDirty();
18602 4517266 }
18603
18604 4414 void screen_combo_modify_pre(int32_t cid)
18605 {
18606 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18607
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18608 {
18609 5195 screen_combo_modify_preroutine(rpos_handle);
18610 5195 }
18611 2808608 });
18612 4414 }
18613 4414 void screen_combo_modify_post(int32_t cid)
18614 {
18615 4414 combo_caches::refresh(cid);
18616
18617 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18618
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18619 {
18620 5195 screen_combo_modify_postroutine(rpos_handle);
18621 5195 }
18622 2808608 });
18623
18624 144186 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18625
2/2
✓ Branch 0 taken 139714 times.
✓ Branch 1 taken 58 times.
139772 if (ffc_handle.data() == cid)
18626 {
18627 58 screen_ffc_modify_postroutine(ffc_handle);
18628 58 }
18629 139772 });
18630 4414 }
18631
18632 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18633 {
18634 94 int cid = rpos_handle.data();
18635 94 int cset = rpos_handle.cset();
18636 282 auto [x, y] = rpos_handle.xy();
18637
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18638 94 }
18639
18640 // It stands for next_side_pos
18641 // moves sle_x and sle_y to the next position
18642 11464 void nsp(bool random)
18643 {
18644
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18645 {
18646
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18647 {
18648 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18649 1634 sle_y = (zc_oldrand()%10)*16;
18650 1634 }
18651 else
18652 {
18653 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18654 1627 sle_x = (zc_oldrand()%15)*16;
18655 }
18656
18657 3261 return;
18658 }
18659
18660
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18661 {
18662
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18663 1855 sle_y+=16;
18664 else
18665 180 sle_x+=16;
18666 2035 }
18667
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18668 {
18669
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18670 2430 sle_x+=16;
18671 else
18672 166 sle_y-=16;
18673 2596 }
18674
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18675 {
18676
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18677 1404 sle_y-=16;
18678 else
18679 148 sle_x-=16;
18680 1552 }
18681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18682 {
18683
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18684 2020 sle_x-=16;
18685 else
18686 sle_y+=16;
18687 2020 }
18688 11464 }
18689
18690 // moves sle_x and sle_y to the next available position
18691 // returns the direction the enemy should face
18692 2429 int32_t next_side_pos(int32_t screen, bool random)
18693 {
18694 bool blocked;
18695 2429 int32_t c=0;
18696 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18697
18698 2429 do
18699 {
18700
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18701 22928 int x = sle_x + offx;
18702 22928 int y = sle_y + offy;
18703
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18704
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18705
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18706
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18707 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18708
18709
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18710 1 return -1;
18711
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18712 11463 while(blocked);
18713
18714 2428 int32_t dir=0;
18715
18716
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18717
18718
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18719
18720
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18721
18722
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18723
18724 2428 return dir;
18725 2429 }
18726
18727 bool can_side_load(int32_t id)
18728 {
18729 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18730 {
18731 return false;
18732 }
18733
18734 id = id&0xFFF;
18735
18736 switch(guysbuf[id].type)
18737 {
18738 case eeTEK:
18739 case eeLEV:
18740 case eeAQUA:
18741 case eeDONGO:
18742 case eeMANHAN:
18743 case eeGLEEOK:
18744 case eeDIG:
18745 case eeGHOMA:
18746 case eeLANM:
18747 case eePATRA:
18748 case eeGANON:
18749 case eePROJECTILE:
18750 return false;
18751 break;
18752 }
18753
18754 return true;
18755 }
18756
18757 bool enemy_spawning_has_checked_been_here;
18758 static bool enemy_spawning_has_been_here;
18759
18760 36680 static bool check_if_recently_visited()
18761 {
18762
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 36158 times.
36680 if (enemy_spawning_has_checked_been_here)
18763 522 return enemy_spawning_has_been_here;
18764
18765 36158 int mi = mapind(cur_map, cur_screen);
18766
18767 36158 enemy_spawning_has_been_here = false;
18768
2/2
✓ Branch 0 taken 216948 times.
✓ Branch 1 taken 36158 times.
253106 for (int i = 0; i < 6; i++)
18769
2/2
✓ Branch 0 taken 206789 times.
✓ Branch 1 taken 10159 times.
227107 if (visited[i] == mi)
18770 10159 enemy_spawning_has_been_here = true;
18771
18772
2/2
✓ Branch 0 taken 10159 times.
✓ Branch 1 taken 25999 times.
36158 if (!enemy_spawning_has_been_here)
18773 {
18774 25999 visited[vhead] = mi; //If not, it adds it to the array,
18775 25999 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18776 25999 }
18777
18778 36158 enemy_spawning_has_checked_been_here = true;
18779 36158 return enemy_spawning_has_been_here;
18780 36680 }
18781
18782 static std::array<bool, MAPSCRS> script_sle;
18783
18784 static int32_t sle_pattern = 0;
18785 static void script_side_load_enemies(mapscr* scr)
18786 {
18787 if (script_sle[scr->screen] || sle_clk) return;
18788
18789 sle_cnt = 0;
18790 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18791 ++sle_cnt;
18792 script_sle[scr->screen] = true;
18793 sle_pattern = scr->pattern;
18794 sle_clk = 0;
18795 }
18796
18797 54516 static void side_load_enemies(mapscr* scr)
18798 {
18799 54516 int screen = scr->screen;
18800
18801
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18802 {
18803 683 sle_pattern = scr->pattern;
18804 683 sle_cnt = 0;
18805 683 int32_t guycnt = 0;
18806
18807 683 int mi = mapind(cur_map, screen);
18808 683 bool reload=true;
18809 683 bool unbeatablereload = true;
18810
18811 683 load_default_enemies(scr);
18812
18813 683 bool beenhere = check_if_recently_visited();
18814
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18815 {
18816 42 sle_cnt=0;
18817 42 reload=false;
18818 42 }
18819
18820
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18821 {
18822 641 sle_cnt = game->guys[mi];
18823
18824
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18825 641 || sle_cnt==0)
18826 {
18827
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18828 1054 ++sle_cnt;
18829 221 }
18830
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18831 {
18832 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18833 {
18834 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18835 {
18836 unbeatablereload = false;
18837 }
18838 }
18839 if (unbeatablereload)
18840 {
18841 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18842 {
18843 ++sle_cnt;
18844 }
18845 }
18846 }
18847 641 }
18848
18849
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18850 {
18851 31 sle_cnt = 0;
18852
18853
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18854 108 ++sle_cnt;
18855 31 }
18856
1/2
✓ Branch 0 taken 683 times.
✗ Branch 1 not taken.
683 if(getmapflag(scr, mNO_ENEMIES_RETURN))
18857 sle_cnt = 0;
18858
18859
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
18860 2446 ++guycnt;
18861
18862 683 game->guys[mi] = guycnt;
18863 683 }
18864
18865
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
18866 {
18867 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
18868 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
18869
18870
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
18871 {
18872 234 return;
18873 }
18874
18875 2195 int32_t enemy_slot=guys.Count();
18876
18877
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
18878 sle_cnt--;
18879
18880
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if(sle_cnt > 0)
18881 {
18882
3/6
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2195 times.
✗ Branch 5 not taken.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
18883 {
18884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->type != eeTEK)
18885 {
18886 2195 guys.spr(enemy_slot)->dir = dir;
18887 2195 }
18888
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
18889 {
18890 if (!FFCore.system_suspend[susptNPCSCRIPTS])
18891 {
18892 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
18893 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
18894 }
18895 }
18896 2195 }
18897 2195 }
18898 2195 }
18899
18900
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
18901 {
18902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
18903 script_sle[screen] = false;
18904 else
18905 {
18906 578 get_screen_state(screen).loaded_enemies = true;
18907 }
18908 578 sle_clk = 0;
18909 578 }
18910 54516 }
18911
18912 1271103 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
18913 {
18914
2/2
✓ Branch 0 taken 117220 times.
✓ Branch 1 taken 1153883 times.
1271103 if (!is_in_scrolling_region())
18915
2/4
✓ Branch 0 taken 1153883 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1153883 times.
1153883 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
18916 {
18917 return false; //never 0, never OoB.
18918 }
18919 // No corner enemies
18920
6/6
✓ Branch 0 taken 1098758 times.
✓ Branch 1 taken 172345 times.
✓ Branch 2 taken 41603 times.
✓ Branch 3 taken 1140361 times.
✓ Branch 4 taken 118860 times.
✓ Branch 5 taken 95088 times.
1271103 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
18921 213948 return false;
18922
18923 //Is a no spawn combo...
18924
4/4
✓ Branch 0 taken 1140351 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1140349 times.
1140361 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
18925 12 return false;
18926
18927 // No enemies in dungeon walls
18928
2/2
✓ Branch 0 taken 485260 times.
✓ Branch 1 taken 655089 times.
1140349 if (isdungeon(scr->screen))
18929 {
18930 655089 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
18931
17/18
✓ Branch 0 taken 655089 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582529 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582529 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509969 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509969 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422897 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422897 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335825 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335825 times.
655089 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
18932 319264 return false;
18933 335825 }
18934
18935 // Too close to hero
18936
4/4
✓ Branch 0 taken 78297 times.
✓ Branch 1 taken 742788 times.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 78157 times.
821085 if(tooclose(x,y,40) && t<11)
18937 78157 return false;
18938
18939 // Can't fly onto it?
18940
4/4
✓ Branch 0 taken 144461 times.
✓ Branch 1 taken 598467 times.
✓ Branch 2 taken 36074 times.
✓ Branch 3 taken 25255 times.
804257 if(isflier(scr->enemy[i])&&
18941
2/2
✓ Branch 0 taken 140466 times.
✓ Branch 1 taken 3995 times.
144461 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
18942
2/2
✓ Branch 0 taken 61329 times.
✓ Branch 1 taken 79137 times.
140466 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
18943 29250 return false;
18944
18945 // Can't jump onto it?
18946 if
18947 (
18948
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88795 times.
802477 guysbuf[scr->enemy[i]].type==eeTEK
18949
18950
2/2
✓ Branch 0 taken 88813 times.
✓ Branch 1 taken 624865 times.
713678 &&
18951 (
18952
2/2
✓ Branch 0 taken 88806 times.
✓ Branch 1 taken 7 times.
88813 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
18953
2/2
✓ Branch 0 taken 88805 times.
✓ Branch 1 taken 1 times.
88806 COMBOTYPE(x+8,y+8)==cNOENEMY||
18954
1/2
✓ Branch 0 taken 88805 times.
✗ Branch 1 not taken.
88805 ispitfall(x+8,y+8)||
18955
2/2
✓ Branch 0 taken 88799 times.
✓ Branch 1 taken 6 times.
88805 MAPFLAG(x+8,y+8)==mfNOENEMY||
18956 88799 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
18957 )
18958 )
18959 {
18960 18 return false;
18961 }
18962
18963 // Other off-limit combos
18964
6/6
✓ Branch 0 taken 598451 times.
✓ Branch 1 taken 115209 times.
✓ Branch 2 taken 509656 times.
✓ Branch 3 taken 88795 times.
✓ Branch 4 taken 280088 times.
✓ Branch 5 taken 229568 times.
1223316 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].type!=eeTEK &&
18965
2/2
✓ Branch 0 taken 287854 times.
✓ Branch 1 taken 221802 times.
509656 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
18966 509656 guysbuf[scr->enemy[i]].type!=eeZORA)
18967 229568 return false;
18968
18969 // Don't ever generate enemies on these combos!
18970
4/4
✓ Branch 0 taken 483786 times.
✓ Branch 1 taken 306 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 483792 times.
484092 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
18971 312 return false;
18972
18973 //BS Dodongos need at least 2 spaces.
18974
4/4
✓ Branch 0 taken 1045 times.
✓ Branch 1 taken 482747 times.
✓ Branch 2 taken 1020 times.
✓ Branch 3 taken 25 times.
483792 if ((guysbuf[scr->enemy[i]].type==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
18975 {
18976
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
18977
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
18978
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
18979 ((y>144)||_walkflag(x, y+24,2)))
18980 {
18981 return false;
18982 }
18983 19 }
18984
18985 483786 return true;
18986 1164131 }
18987
18988 168020 bool is_ceiling_pattern(int32_t i)
18989 {
18990
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 167798 times.
168020 return (i==pCEILING || i==pCEILINGR);
18991 }
18992
18993 6001 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
18994 {
18995 6001 std::vector<rpos_t> freeposcache;
18996
18997
2/2
✓ Branch 0 taken 66011 times.
✓ Branch 1 taken 6001 times.
72012 for(int32_t y=offy; y<offy+176; y+=16)
18998 {
18999
2/2
✓ Branch 0 taken 1056176 times.
✓ Branch 1 taken 66011 times.
1122187 for(int32_t x=offx; x<offx+256; x+=16)
19000 {
19001
3/4
✓ Branch 0 taken 1056176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 422575 times.
✓ Branch 3 taken 633601 times.
1056176 if(is_starting_pos(scr,i,x,y,0))
19002 {
19003
2/4
✓ Branch 0 taken 422575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 422575 times.
✗ Branch 3 not taken.
422575 freeposcache.push_back(COMBOPOS_REGION(x, y));
19004 422575 }
19005 1056176 }
19006 66011 }
19007
19008
2/2
✓ Branch 0 taken 5989 times.
✓ Branch 1 taken 12 times.
6001 if (!freeposcache.empty())
19009
1/2
✓ Branch 0 taken 5989 times.
✗ Branch 1 not taken.
5989 return freeposcache[zc_oldrand()%freeposcache.size()];
19010
19011 12 return rpos_t::None;
19012 6001 }
19013
19014 84843 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19015 {
19016 84843 int screen = scr->screen;
19017 84843 int x = 0;
19018 84843 int y = 0;
19019 84843 bool placed=false;
19020 84843 int32_t t=-1;
19021
19022 // First: enemy combo flags
19023
2/2
✓ Branch 0 taken 844917 times.
✓ Branch 1 taken 67212 times.
912129 for(int32_t sy=0; sy<176; sy+=16)
19024 {
19025
2/2
✓ Branch 0 taken 13387597 times.
✓ Branch 1 taken 827286 times.
14214883 for(int32_t sx=0; sx<256; sx+=16)
19026 {
19027 13387597 x = offx + sx;
19028 13387597 y = offy + sy;
19029 13387597 int32_t cflag = MAPFLAG(x, y);
19030 13387597 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19031
19032
2/4
✓ Branch 0 taken 13387597 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13387597 times.
✗ Branch 3 not taken.
13387597 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19033 {
19034 if(!ok2add(scr, scr->enemy[i]))
19035 {
19036 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19037 }
19038 else
19039 {
19040 addenemy_z(screen,x,
19041 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19042 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19043
19044 ++guycnt;
19045
19046 placed=true;
19047 goto placed_enemy;
19048 }
19049 }
19050
19051
4/4
✓ Branch 0 taken 13369917 times.
✓ Branch 1 taken 17680 times.
✓ Branch 2 taken 13369917 times.
✓ Branch 3 taken 17680 times.
13387597 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19052 {
19053
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17631 times.
17680 if(!ok2add(scr, scr->enemy[i]))
19054 {
19055
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19056 49 }
19057 else
19058 {
19059 35262 addenemy_z(screen,x,
19060
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17630 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17631 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19061
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17631 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19062
19063 17631 ++guycnt;
19064
19065 17631 placed=true;
19066 17631 goto placed_enemy;
19067 }
19068 49 }
19069 13369966 }
19070 827286 }
19071
19072 // Next: enemy pattern
19073
6/8
✓ Branch 0 taken 5098 times.
✓ Branch 1 taken 62114 times.
✓ Branch 2 taken 61478 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 61478 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 61478 times.
67212 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19074 {
19075 61478 do
19076 {
19077
19078 // NES positions
19079 108222 pos%=9;
19080 108222 x=offx+stx[loadside][pos];
19081 108222 y=offy+sty[loadside][pos];
19082 108222 ++pos;
19083 108222 ++t;
19084
2/2
✓ Branch 0 taken 46744 times.
✓ Branch 1 taken 61478 times.
169700 }
19085
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 107955 times.
108222 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19086 61478 }
19087
19088
4/4
✓ Branch 0 taken 61478 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 267 times.
✓ Branch 3 taken 61211 times.
67212 if(t<0 || t >= 20) // above enemy pattern failed
19089 {
19090 // Final chance: find a random position anywhere onscreen
19091 6001 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19092
19093
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5989 times.
6001 if (rand_rpos != rpos_t::None)
19094 {
19095 5989 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19096 5989 }
19097 else // All opportunities failed - abort
19098 {
19099 12 return;
19100 }
19101 5989 }
19102
19103 {
19104 67200 int32_t c=0;
19105 67200 c=clk;
19106
19107
2/2
✓ Branch 0 taken 10334 times.
✓ Branch 1 taken 56866 times.
67200 if(!slowguy(scr->enemy[i]))
19108 56866 ++fastguys;
19109
2/2
✓ Branch 0 taken 1768 times.
✓ Branch 1 taken 8566 times.
10334 else if(fastguys>0)
19110 1768 c=-15*(i-fastguys+2);
19111 else
19112 8566 c=-15*(i+1);
19113
19114
4/6
✓ Branch 0 taken 32607 times.
✓ Branch 1 taken 34593 times.
✓ Branch 2 taken 32607 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 32607 times.
67200 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19115 {
19116 // Special case for blue leevers
19117
4/4
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 30243 times.
✓ Branch 2 taken 1189 times.
✓ Branch 3 taken 1175 times.
32607 if(guysbuf[scr->enemy[i]].type==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19118 1189 c=-15*(i+1);
19119 else
19120 31418 c=-15;
19121 32607 }
19122
19123
2/2
✓ Branch 0 taken 66379 times.
✓ Branch 1 taken 821 times.
67200 if(!ok2add(scr, scr->enemy[i]))
19124 {
19125
4/6
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 685 times.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 136 times.
821 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19126 821 }
19127 else
19128 {
19129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66379 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66379 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19130 {
19131
3/4
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 66102 times.
✓ Branch 2 taken 277 times.
✗ Branch 3 not taken.
132758 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19132
3/4
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 66102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 277 times.
66379 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19133
19134 66379 ++guycnt;
19135 66379 }
19136 }
19137
19138 67200 placed=true;
19139 67200 } // if(t < 20)
19140
19141 placed_enemy:
19142
19143 // I don't like this, but it seems to work...
19144 static bool foundCarrier;
19145
19146
2/2
✓ Branch 0 taken 62100 times.
✓ Branch 1 taken 22731 times.
84831 if(i==0)
19147 22731 foundCarrier=false;
19148
19149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84831 times.
84831 if(placed)
19150 {
19151
4/4
✓ Branch 0 taken 22731 times.
✓ Branch 1 taken 62100 times.
✓ Branch 2 taken 22550 times.
✓ Branch 3 taken 181 times.
84831 if(i==0 && scr->flags11&efLEADER)
19152 {
19153 181 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19154
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 7 times.
181 if (e)
19155 {
19156 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19157
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
174 if ((e->type == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19158 {
19159 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19160 }
19161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if (e)
19162 {
19163 174 e->leader = true;
19164 174 }
19165 174 }
19166 181 }
19167
19168 84831 ScreenItemState item_state = get_screen_state(screen).item_state;
19169
5/6
✓ Branch 0 taken 84587 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 84587 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 84503 times.
84831 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19170 {
19171 84 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19172
2/4
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
84 if (e && (e->flags&guy_doesnt_count)==0)
19173 {
19174 84 e->itemguy = true;
19175 84 foundCarrier=true;
19176 84 }
19177 84 }
19178 84831 }
19179 84843 }
19180
19181 // returns index of first sprite with matching id, -1 if none found
19182 265 enemy* find_guy_first_for_id(int screen, int id, int mask)
19183 {
19184 265 int count = guys.Count();
19185
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 7 times.
392 for (int32_t i=0; i<count; i++)
19186 {
19187 385 enemy* e = (enemy*)guys.spr(i);
19188
4/4
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 258 times.
✓ Branch 3 taken 79 times.
385 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19189 {
19190 258 return e;
19191 }
19192 127 }
19193
19194 7 return nullptr;
19195 265 }
19196
19197 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19198 {
19199 int count = guys.Count();
19200 for(int32_t i=0; i<count; i++)
19201 {
19202 enemy* e = (enemy*)guys.spr(i);
19203 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19204 {
19205 if (n > 1) --n;
19206 else return e;
19207 }
19208 }
19209 return nullptr;
19210 }
19211
19212 14 bool scriptloadenemies(int screen)
19213 {
19214 // https://discord.com/channels/876899628556091432/1395904851908755577
19215
5/14
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 14 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
28 bool replay_compat_enemies_load_bug = replay_is_active() && replay_get_meta_bool("compat_scriptloadenemies");
19216 14 auto& state = get_screen_state(screen);
19217
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_compat_enemies_load_bug)
19218 state.loaded_enemies = true;
19219
19220
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (sle_clk || script_sle[screen]) return false;
19221
19222 14 mapscr* scr = get_scr(screen);
19223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(scr->pattern==pNOSPAWN) return false;
19224
19225
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19226 {
19227 script_side_load_enemies(scr);
19228 return true;
19229 }
19230
19231 184 auto [x, y] = translate_screen_coordinates_to_world(screen);
19232 14 int32_t pos=zc_oldrand()%9;
19233 14 int32_t clk=-15,fastguys=0;
19234 14 int32_t i=0,guycnt=0;
19235 14 int32_t loadcnt = 10;
19236
19237
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 14 times.
99 for(; i<loadcnt && scr->enemy[i]>0; i++)
19238 {
19239 85 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19240 255 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (guys.Count() > preguycount)
19242 {
19243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19244 {
19245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19246 {
19247 85 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19248 85 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19249 85 }
19250 85 }
19251 85 }
19252 85 --clk;
19253 85 }
19254 14 return true;
19255 14 }
19256
19257 14793719 void loadenemies()
19258 {
19259 29967596 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19260 15173877 int screen = scr->screen;
19261 15173877 auto& state = get_screen_state(screen);
19262
2/2
✓ Branch 0 taken 14757013 times.
✓ Branch 1 taken 416864 times.
15173877 if (state.loaded_enemies)
19263 14757013 return;
19264
19265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416864 times.
416864 if(getmapflag(scr, mNO_ENEMIES_RETURN))
19266 {
19267 state.loaded_enemies = true;
19268 return;
19269 }
19270
19271 // dungeon basements
19272 static byte dngn_enemy_x[4] = {32,96,144,208};
19273
2/2
✓ Branch 0 taken 148964 times.
✓ Branch 1 taken 267900 times.
416864 if (cur_screen>=128)
19274 {
19275
2/2
✓ Branch 0 taken 148489 times.
✓ Branch 1 taken 475 times.
148964 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19277 {
19278 for(int32_t i=0; i<10; i++)
19279 {
19280 if ( scr->enemy[i] )
19281 {
19282 int32_t preguycount = guys.Count();
19283 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19284 if (guys.Count() > preguycount)
19285 {
19286 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19287 {
19288 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19289 {
19290 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19291 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19292 }
19293 }
19294 }
19295 }
19296 }
19297 }
19298 else
19299 {
19300
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19301 {
19302 1900 int32_t preguycount = guys.Count();
19303
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19305 {
19306
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19307 {
19308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19309 {
19310 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19311 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19312 4 }
19313 4 }
19314 1900 }
19315 1900 }
19316 }
19317
19318 475 state.loaded_enemies = true;
19319 475 return;
19320 }
19321
19322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267900 times.
267900 if (scr->pattern == pNOSPAWN)
19323 return;
19324
19325 // TODO: configure when screen enemies spawn.
19326
2/2
✓ Branch 0 taken 90608 times.
✓ Branch 1 taken 177292 times.
267900 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19327 177292 return;
19328
19329
4/4
✓ Branch 0 taken 52161 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 36092 times.
90608 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19330 {
19331 54516 side_load_enemies(scr);
19332 54516 return;
19333 }
19334
19335 36092 state.loaded_enemies = true;
19336
19337 // check if it's the dungeon boss and it has been beaten before
19338
4/4
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 35714 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 95 times.
36092 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&(1 << li_boss_killed))
19339 95 return;
19340
19341 35997 int32_t loadcnt = 10;
19342 35997 int16_t mi = mapind(cur_map, screen);
19343 35997 bool beenhere = check_if_recently_visited();
19344
19345 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19346 35997 bool reload = true;
19347
4/4
✓ Branch 0 taken 10302 times.
✓ Branch 1 taken 25695 times.
✓ Branch 2 taken 5031 times.
✓ Branch 3 taken 5271 times.
35997 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19348 {
19349 5271 loadcnt = 0; //It will tell it not to load any enemies,
19350 5271 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19351 5271 }
19352
19353 35997 bool unbeatablereload = true;
19354
2/2
✓ Branch 0 taken 5271 times.
✓ Branch 1 taken 30726 times.
35997 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19355 {
19356 30726 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19357
19358
2/4
✓ Branch 0 taken 11007 times.
✓ Branch 1 taken 19719 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30726 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11007 times.
11007 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19360 19719 loadcnt = 10; //That means all enemies need to be respawned.
19361
3/4
✓ Branch 0 taken 25695 times.
✓ Branch 1 taken 5031 times.
✓ Branch 2 taken 25695 times.
✗ Branch 3 not taken.
30726 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19362 {
19363 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19364 {
19365 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19366 {
19367 unbeatablereload = false;
19368 }
19369 }
19370 if (unbeatablereload)
19371 {
19372 loadcnt = 10;
19373 }
19374 }
19375 30726 }
19376
19377
4/4
✓ Branch 0 taken 34536 times.
✓ Branch 1 taken 1461 times.
✓ Branch 2 taken 212 times.
✓ Branch 3 taken 34324 times.
35997 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19378 1673 loadcnt = 10; //All enemies also need to be respawned.
19379
19380 // do enemies that are always loaded
19381 35997 load_default_enemies(scr);
19382 35997 activate_fireball_statues(scr);
19383
19384 35997 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19385 35997 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19386 35997 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19387
4/4
✓ Branch 0 taken 16124 times.
✓ Branch 1 taken 104631 times.
✓ Branch 2 taken 84758 times.
✓ Branch 3 taken 35997 times.
120755 for(; i<loadcnt && scr->enemy[i]>0; i++)
19388 {
19389 84758 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19390 84758 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19391
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 83925 times.
84758 if (guys.Count() > preguycount)
19392 {
19393
2/2
✓ Branch 0 taken 77968 times.
✓ Branch 1 taken 5957 times.
83925 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19394 {
19395
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5953 times.
5957 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19396 {
19397 5953 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19398 5953 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19399 5953 }
19400 5957 }
19401 83925 }
19402
19403 84758 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19404 84758 }
19405
19406 35997 game->guys[mi] = guycnt;
19407 15173877 });
19408 14793719 }
19409
19410 233 void moneysign()
19411 {
19412 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19413 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19414 233 set_clip_state(pricesdisplaybuf, 0);
19415 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19416 233 }
19417
19418 3416 void putprices(bool sign)
19419 {
19420
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3384 times.
3416 if(fadeclk > 0) return;
19421
19422 3384 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19423 3384 int32_t step=32;
19424 3384 int32_t x=80;
19425
19426
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 3103 times.
3384 if(prices[2]==0)
19427 {
19428 3103 step<<=1;
19429
19430
2/2
✓ Branch 0 taken 3071 times.
✓ Branch 1 taken 32 times.
3103 if(prices[1]==0)
19431 {
19432 3071 x=112;
19433 3071 }
19434 3103 }
19435
19436
2/2
✓ Branch 0 taken 3384 times.
✓ Branch 1 taken 10152 times.
13536 for(int32_t i=0; i<3; i++)
19437 {
19438 // Kind of stupid, but it works: 100000 is used to indicate that an item
19439 // has a price of zero rather than there being no item.
19440 // 100000 isn't a valid price, so this doesn't cause problems.
19441
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 9113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
10152 if(prices[i]!=0 && prices[i]<100000)
19442 {
19443 char buf[8];
19444 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19445
19446 1039 int32_t l=(int32_t)strlen(buf);
19447 1039 set_clip_state(pricesdisplaybuf, 0);
19448
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19449 1039 }
19450
19451 10152 x+=step;
19452 10152 }
19453 3416 }
19454
19455 // Setting up special rooms
19456 // Also called when the Letter is used successfully.
19457 1217 void setupscreen()
19458 {
19459 1217 boughtsomething=false;
19460
19461 // Either the origin screen, or if in a 0x80 room the screen player came from.
19462
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 801 times.
1217 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19463 1217 mapscr* scr = origin_scr;
19464
19465 1217 word str=base_scr->str;
19466
19467 2269 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19468
19469 // Prices are already set to 0 in dowarp()
19470
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1217 switch(base_scr->room)
19471 {
19472 case rSP_ITEM: // special item
19473 328 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19474 164 break;
19475
19476 case rINFO: // pay for info
19477 {
19478 28 int32_t count = 0;
19479 28 int32_t base = 88;
19480 28 int32_t step = 5;
19481
19482 28 moneysign();
19483
19484
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19485 {
19486
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19487 {
19488 84 ++count;
19489 84 }
19490 else
19491 break;
19492 84 }
19493
19494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19495 {
19496
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19497 {
19498 base = 88+32;
19499 }
19500
19501
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19502 {
19503 step = 6;
19504 }
19505
19506
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19507 {
19508 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19509 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19510 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19511
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19512 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19513 84 int32_t itemid = current_item_id(itype_wealthmedal);
19514
19515
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19516 {
19517 if(itemsbuf[itemid].flags & item_flag1)
19518 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19519 else
19520 prices[i]-=itemsbuf[itemid].misc1;
19521 prices[i]=vbound(prices[i], -99999, 0);
19522 if(prices[i]==0)
19523 prices[i]=100000;
19524 }
19525
19526
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19527 prices[i]=-1;
19528 84 }
19529 28 }
19530
19531 28 break;
19532 }
19533
19534 case rMONEY: // secret money
19535 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19536 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19537 44 break;
19538
19539 case rGAMBLE: // gambling
19540 11 prices[0]=prices[1]=prices[2]=-10;
19541 11 moneysign();
19542 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19543 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19544 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19545 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19546 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19547 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19548 11 break;
19549
19550 case rREPAIR: // door repair
19551
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19552 // }
19553 13 repaircharge=base_scr->catchall;
19554 13 break;
19555
19556 case rMUPGRADE: // upgrade magic
19557 2 adjustmagic=true;
19558 2 break;
19559
19560 case rLEARNSLASH: // learn slash attack
19561 2 learnslash=true;
19562 2 break;
19563
19564 case rRP_HC: // heart container or red potion
19565 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19566 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19567 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19568 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19569 17 break;
19570
19571 case rP_SHOP: // potion shop
19572
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19573 {
19574 12 str=0;
19575 12 break;
19576 }
19577
19578 [[fallthrough]];
19579 case rTAKEONE: // take one
19580 case rSHOP: // shop
19581 {
19582 194 int32_t count = 0;
19583 194 int32_t base = 88;
19584 194 int32_t step = 5;
19585
19586
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19587 193 moneysign();
19588
19589 //count and align the stuff
19590
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19591 {
19592
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19593 {
19594 523 ++count;
19595 523 }
19596 else
19597 {
19598 37 break;
19599 }
19600 523 }
19601
19602
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19603 {
19604 22 base = 88+32;
19605 22 }
19606
19607
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19608 {
19609 15 step = 6;
19610 15 }
19611
19612
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19613 {
19614 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19615 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19616
19617
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19618 {
19619 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19620
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19621 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19622 521 int32_t itemid = current_item_id(itype_wealthmedal);
19623
19624
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19625 {
19626
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19627 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19628 else
19629 prices[i]+=itemsbuf[itemid].misc1;
19630 9 prices[i]=vbound(prices[i], 0, 99999);
19631
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19632 prices[i]=100000;
19633 9 }
19634
19635
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19636 prices[i]=1;
19637 521 }
19638 523 }
19639
19640 194 break;
19641 }
19642 case rBOTTLESHOP: // bottle shop
19643 {
19644 1 int32_t count = 0;
19645 1 int32_t base = 88;
19646 1 int32_t step = 5;
19647
19648 1 moneysign();
19649 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19650 //count and align the stuff
19651
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19652 {
19653
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19654 {
19655 3 ++count;
19656 3 }
19657 else
19658 {
19659 break;
19660 }
19661 3 }
19662
19663
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19664 {
19665 base = 88+32;
19666 }
19667
19668
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19669 {
19670 step = 6;
19671 }
19672
19673
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19674 {
19675 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19676 //{ Setup dummy item
19677 3 item* curItem = ((item*)items.spr(items.Count()-1));
19678 3 curItem->PriceIndex = i;
19679 3 newcombo const& cmb = combobuf[bst.comb[i]];
19680
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(cmb.animflags & AF_EDITOR_ONLY)
19681 {
19682 curItem->yofs = -32768;
19683 }
19684 3 curItem->o_tile = cmb.o_tile;
19685 3 curItem->o_cset = bst.cset[i];
19686 3 curItem->cs = curItem->o_cset;
19687 3 curItem->tile = cmb.o_tile;
19688 3 curItem->o_speed = cmb.speed;
19689 3 curItem->o_delay = 0;
19690 3 curItem->frames = cmb.frames;
19691 3 curItem->flip = cmb.flip;
19692 3 curItem->type = itype_bottlefill; //no pickup w/o empty bottle
19693 3 curItem->pstring = 0;
19694 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19695 3 curItem->flash = false;
19696 3 curItem->twohand = false;
19697 3 curItem->anim = true;
19698 3 curItem->hit_width=1;
19699 3 curItem->hyofs=4;
19700 3 curItem->hit_height=12;
19701 3 curItem->script=0;
19702 3 curItem->txsz=1;
19703 3 curItem->tysz=1;
19704 //}
19705
19706 3 prices[i] = bst.price[i];
19707
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19708 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19709 3 int32_t itemid = current_item_id(itype_wealthmedal);
19710
19711
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19712 {
19713 if(itemsbuf[itemid].flags & item_flag1)
19714 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19715 else
19716 prices[i]+=itemsbuf[itemid].misc1;
19717 prices[i]=vbound(prices[i], 0, 99999);
19718 if(prices[i]==0)
19719 prices[i]=100000;
19720 }
19721
19722
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19723 prices[i]=1;
19724 3 }
19725
19726 1 break;
19727 }
19728
19729 case rBOMBS: // more bombs
19730 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19731 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19732 19 prices[0]=-base_scr->catchall;
19733 19 break;
19734
19735 case rARROWS: // more arrows
19736 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19737 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19738 prices[0]=-base_scr->catchall;
19739 break;
19740
19741 case rSWINDLE: // leave heart container or money
19742 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19743 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19744 14 prices[0]=-1;
19745 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19746 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19747 14 prices[1]=-base_scr->catchall;
19748 14 break;
19749
19750 }
19751
19752
3/4
✓ Branch 0 taken 1198 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1198 times.
1217 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19753 {
19754 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19755 19 int32_t itemid = current_item_id(itype_wealthmedal);
19756
19757
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19758 {
19759 if(itemsbuf[itemid].flags & item_flag1)
19760 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19761 else
19762 prices[i]+=itemsbuf[itemid].misc1;
19763 }
19764
19765
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19766 prices[i]=-1;
19767 19 }
19768
19769 1217 putprices(false);
19770
19771
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 59 times.
1217 if(str)
19772 {
19773 1158 donewmsg(base_scr, str);
19774 1158 }
19775 else
19776 {
19777 59 Hero.unfreeze();
19778 }
19779 1217 }
19780
19781 enum
19782 {
19783 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19784 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19785
19786 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19787
19788 MNU_DATA_MAX
19789 };
19790 struct menu_choice
19791 {
19792 int32_t x, y;
19793 int32_t pos;
19794 int32_t upos, dpos, lpos, rpos;
19795 24 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19796 24 {}
19797 24 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19798 int32_t dpos, int32_t lpos, int32_t rpos)
19799 24 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19800 24 {}
19801 };
19802 static int32_t msg_menu_data[MNU_DATA_MAX];
19803 static bool do_run_menu = false;
19804 bool do_end_str = false;
19805 static bool wait_advance = false;
19806 430 static std::map<int32_t, menu_choice> menu_options;
19807 46351 void clr_msg_data()
19808 {
19809 46351 do_end_str = false;
19810 46351 wait_advance = false;
19811 46351 do_run_menu = false;
19812 46351 menu_options.clear();
19813 46351 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19814 46351 }
19815
19816 static char namebuf[9] = {0};
19817 static char* nameptr = NULL;
19818 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19819 2123 bool runMenuCursor()
19820 {
19821 2123 clear_bitmap(msg_menu_bmp_buf);
19822
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 if(!menu_options.size())
19823 {
19824 msg_menu_data[MNU_CHOSEN] = 0;
19825 return true; //end menu
19826 }
19827 2123 int32_t pos = msg_menu_data[MNU_CHOSEN];
19828 //If the cursor is at an invalid pos, find the first pos >= 0...
19829
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 if(menu_options.find(pos) == menu_options.end())
19830 {
19831 pos = 0;
19832 while(menu_options.find(pos) == menu_options.end())
19833 ++pos;
19834 }
19835 2123 menu_choice* ch = &menu_options[pos];
19836
19837 2123 bool pressed = true;
19838
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2119 times.
2123 if(getInput(btnUp, INPUT_PRESS)) pos = ch->upos;
19839
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2117 times.
2119 else if(getInput(btnDown, INPUT_PRESS)) pos = ch->dpos;
19840
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2108 times.
2117 else if(getInput(btnLeft, INPUT_PRESS)) pos = ch->lpos;
19841
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2097 times.
2108 else if(getInput(btnRight, INPUT_PRESS)) pos = ch->rpos;
19842 2097 else pressed = false;
19843
19844
2/2
✓ Branch 0 taken 2097 times.
✓ Branch 1 taken 26 times.
2123 if(pressed)
19845 26 msg_menu_data[MNU_TIMER] = 1;
19846
19847 2123 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19848 2123 bool held = false;
19849
2/2
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 95 times.
2123 if(hold_input)
19850 {
19851 95 held = true;
19852
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 94 times.
95 if(getInput(btnUp)) pos = ch->upos;
19853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 else if(getInput(btnDown)) pos = ch->dpos;
19854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 else if(getInput(btnLeft)) pos = ch->lpos;
19855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 else if(getInput(btnRight)) pos = ch->rpos;
19856 94 else held = false;
19857 95 }
19858 //If the cursor is at an invalid pos, find the first pos >= 0...
19859
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 if(menu_options.find(pos) == menu_options.end())
19860 {
19861 pos = 0;
19862 while(menu_options.find(pos) == menu_options.end())
19863 ++pos;
19864 }
19865
4/4
✓ Branch 0 taken 2097 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2096 times.
✓ Branch 3 taken 27 times.
2123 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19866 27 sfx(MsgStrings[msgstr].sfx);
19867
19868 2123 ch = &menu_options[pos];
19869 4246 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
19870 2123 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
19871 2123 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
19872 2123 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
19873
19874 2123 msg_menu_data[MNU_CHOSEN] = pos;
19875
19876
2/2
✓ Branch 0 taken 1507 times.
✓ Branch 1 taken 616 times.
2123 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
19877 {
19878 616 getInput(btnA, INPUT_PRESS); //Eat
19879
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 6 times.
616 if(!getInput(btnA)) msg_menu_data[MNU_CAN_CONFIRM] = 1;
19880 616 }
19881
19882
4/4
✓ Branch 0 taken 2097 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2096 times.
2123 bool ret = (pressed || held) ? false : getInput(btnA, INPUT_PRESS);
19883 //Eat inputs
19884 2123 getInput(btnUp, INPUT_PRESS);
19885 2123 getInput(btnDown, INPUT_PRESS);
19886 2123 getInput(btnLeft, INPUT_PRESS);
19887 2123 getInput(btnRight, INPUT_PRESS);
19888 2123 getInput(btnA, INPUT_PRESS);
19889
19890
2/2
✓ Branch 0 taken 2117 times.
✓ Branch 1 taken 6 times.
2123 if(ret)
19891 6 menu_options.clear();
19892
19893 2123 return ret;
19894 //false if pos changed this frame; no confirming while moving the cursor!
19895 2123 }
19896
19897 923258 bool bottom_margin_clip()
19898 {
19899 1058359 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
19900
2/2
✓ Branch 0 taken 788157 times.
✓ Branch 1 taken 135101 times.
923258 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
19901 }
19902
19903 void update_msgstr();
19904
19905 3751 static bool parsemsgcode(const StringCommand& command)
19906 {
19907 3751 auto& args = command.args;
19908 3751 int last_arg = 0;
19909
19910
21/56
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1282 times.
✓ Branch 4 taken 2072 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 64 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 70 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 11 times.
✓ Branch 16 taken 23 times.
✓ Branch 17 taken 7 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 123 times.
✓ Branch 36 taken 28 times.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✓ Branch 43 taken 6 times.
✓ Branch 44 taken 24 times.
✓ Branch 45 taken 6 times.
✓ Branch 46 taken 8 times.
✗ Branch 47 not taken.
✓ Branch 48 taken 3 times.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
3751 switch (command.code)
19911 {
19912 case MSGC_NEWLINE:
19913 {
19914 1282 ssc_tile_hei = ssc_tile_hei_buf;
19915
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 4 times.
1282 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
19916 1282 ssc_tile_hei_buf = -1;
19917 1282 cursor_y += thei + MsgStrings[msgstr].vspace;
19918 1282 cursor_x=msg_margins[left];
19919 1282 return true;
19920 }
19921
19922 case MSGC_COLOUR:
19923 {
19924 2072 int32_t cset = args[0];
19925 2072 msgcolour = CSET(cset)+(args[1]);
19926 2072 return true;
19927 }
19928
19929 case MSGC_SHDCOLOR:
19930 {
19931 int32_t cset = args[0];
19932 msg_shdcol = CSET(cset)+args[1];
19933 return true;
19934 }
19935 case MSGC_SHDTYPE:
19936 {
19937 msg_shdtype = args[0];
19938 return true;
19939 }
19940
19941 case MSGC_SPEED:
19942 {
19943 64 msgspeed=args[0];
19944 64 return true;
19945 }
19946
19947 case MSGC_CTRUP:
19948 {
19949 int32_t a1 = args[0];
19950 int32_t a2 = args[1];
19951 game->change_counter(a2, a1);
19952 return true;
19953 }
19954
19955 case MSGC_CTRDN:
19956 {
19957 5 int32_t a1 = args[0];
19958 5 int32_t a2 = args[1];
19959 5 game->change_counter(-a2, a1);
19960 5 return true;
19961 }
19962
19963 case MSGC_CTRSET:
19964 {
19965 7 int32_t a1 = args[0];
19966 7 int32_t a2 = args[1];
19967 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
19968 7 return true;
19969 }
19970
19971 case MSGC_CTRUPPC:
19972 case MSGC_CTRDNPC:
19973 case MSGC_CTRSETPC:
19974 {
19975 2 int32_t counter = args[0];
19976 2 int32_t amount = args[1];
19977 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
19978
19979
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
19980 amount*=-1;
19981
19982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
19983 game->set_counter(amount, counter);
19984 else
19985 2 game->change_counter(amount, counter);
19986
19987 2 return true;
19988 }
19989
19990 case MSGC_GIVEITEM:
19991 {
19992 70 int32_t itemID = args[0];
19993
19994 70 getitem(itemID, true);
19995
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
19996 {
19997 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
19998 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
19999 70 }
20000 70 return true;
20001 }
20002
20003 case MSGC_COLLECTITEM:
20004 {
20005 6 int32_t itemID = args[0];
20006
20007
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!items.has_space())
20008 {
20009 Z_error("SCC: No room to spawn item\n");
20010 return true;
20011 }
20012
20013 6 additem(0, (get_qr(qr_NOITEMOFFSET) ? 1: 0), itemID, ipHOLDUP);
20014 6 auto* s = (item*)items.spr(items.Count() - 1);
20015 6 s->screen_spawned = msgscr->screen;
20016 6 s->set_forcegrab(true);
20017 // The item will be collected by Hero::checkItems when the message box closes. However,
20018 // if qr_MSGFREEZE is off, this command will instantly close the message box. It's
20019 // expected that new quests have that QR on.
20020 6 return true;
20021 }
20022
20023 case MSGC_WARP:
20024 {
20025 1 int32_t dmap = args[0];
20026 1 int32_t scrn = args[1];
20027 1 int32_t dx = args[2];
20028 1 int32_t dy = args[3];
20029 1 int32_t wfx = args[4];
20030 1 int32_t sfx = args[5];
20031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(dx >= 65023) dx = -1;
20032
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(dy >= 65023) dy = -1;
20033 1 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20034 1 do_end_str = true;
20035 1 return true;
20036 }
20037
20038 case MSGC_SETSCREEND:
20039 {
20040 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20041 int32_t screen = args[1];
20042 int32_t reg = args[2];
20043 int32_t val = args[3];
20044 FFCore.set_screen_d(screen + dmap, reg, val);
20045 return true;
20046 }
20047 case MSGC_TAKEITEM:
20048 {
20049 11 int32_t itemID = args[0];
20050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20051 {
20052 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20053 }
20054 11 takeitem(itemID);
20055
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20056 {
20057 game->forced_bwpn = -1;
20058 } //not else if! -Z
20059
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20060 {
20061 game->forced_awpn = -1;
20062 }
20063
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20064 {
20065 game->forced_xwpn = -1;
20066 } //not else if! -Z
20067
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20068 {
20069 game->forced_ywpn = -1;
20070 }
20071 11 verifyBothWeapons();
20072 11 return true;
20073 }
20074
20075 case MSGC_SFX:
20076 {
20077 23 sfx(args[0]);
20078 23 return true;
20079 }
20080
20081 case MSGC_MIDI:
20082 {
20083 7 int32_t music = args[0];
20084
20085
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20086 1 music_stop();
20087 else
20088 6 jukebox(music+MIDIOFFSET_ZSCRIPT);
20089
20090 7 return true;
20091 }
20092
20093 case MSGC_FONT:
20094 {
20095 int fontid = args[0];
20096 int oh = text_height(msgfont);
20097 msgfont = get_zc_font(fontid);
20098 int nh = text_height(msgfont);
20099 int mh = std::max(oh,nh);
20100 if(mh > ssc_tile_hei_buf)
20101 ssc_tile_hei_buf = mh;
20102 return true;
20103 }
20104 case MSGC_RUN_FRZ_GENSCR:
20105 {
20106 word scr_id = args[0];
20107 bool force_redraw = args[1]!=0;
20108 if(force_redraw)
20109 {
20110 update_msgstr();
20111 draw_screen();
20112 }
20113 FFCore.runGenericFrozenEngine(scr_id);
20114 return true;
20115 }
20116 case MSGC_DRAWTILE:
20117 {
20118 int32_t tl = args[0];
20119 int32_t cs = args[1];
20120 int32_t t_wid = args[2];
20121 int32_t t_hei = args[3];
20122 int32_t fl = args[4];
20123
20124 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20125 {
20126 ssc_tile_hei = ssc_tile_hei_buf;
20127 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20128 ssc_tile_hei_buf = -1;
20129 cursor_y += thei + MsgStrings[msgstr].vspace;
20130 if(bottom_margin_clip()) return true;
20131 cursor_x=msg_margins[left];
20132 }
20133
20134 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20135 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20136 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20137 return true;
20138 }
20139
20140 case MSGC_GOTOIFRAND:
20141 {
20142 1 int32_t odds = args[0];
20143
20144 1 last_arg = 1;
20145
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20146 1 goto switched;
20147
20148 return true;
20149 }
20150
20151 case MSGC_GOTOIFSCREEND:
20152 {
20153 int32_t arg = args[0];
20154 int32_t d = zc_min(7,arg);
20155 int32_t s = ((get_currdmap())<<7) + msgscr->screen-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20156 arg = args[1];
20157
20158 if(game->screen_d[s][d] >= arg)
20159 {
20160 last_arg = 2;
20161 goto switched;
20162 }
20163
20164 return true;
20165 }
20166
20167 case MSGC_GOTOIFGLOBALSTATE:
20168 {
20169 int32_t index = args[0];
20170 bool value = args[1];
20171
20172 if (unsigned(index) >= NUM_GSWITCHES)
20173 {
20174 Z_error("SCC: Global state %d is invalid\n", index);
20175 return true;
20176 }
20177
20178 bool state = game->gswitch_timers[index] != 0;
20179
20180 if (state == value)
20181 {
20182 last_arg = 2;
20183 goto switched;
20184 }
20185
20186 return true;
20187 }
20188
20189 case MSGC_SETGLOBALSTATE:
20190 {
20191 int32_t index = args[0];
20192 int32_t value = args[1];
20193
20194 if (unsigned(index) >= NUM_GSWITCHES)
20195 {
20196 Z_error("SCC: Global state %d is invalid\n", index);
20197 return true;
20198 }
20199
20200 if (bool(game->gswitch_timers[index]) != bool(value))
20201 toggle_gswitches(index, false);
20202 game->gswitch_timers[index] = value;
20203
20204 return true;
20205 }
20206
20207 case MSGC_GOTOIFSCREENSTATE:
20208 {
20209 int32_t flag = args[0];
20210 bool value = args[1];
20211
20212 if (unsigned(flag) >= mMAXIND)
20213 {
20214 Z_error("SCC: Screen state %d is invalid\n", flag);
20215 return true;
20216 }
20217
20218 bool state = getmapflag(msgscr, 1<<flag);
20219 if (state == value)
20220 {
20221 last_arg = 2;
20222 goto switched;
20223 }
20224
20225 return true;
20226 }
20227
20228 case MSGC_GOTOIFANYSCREENSTATE:
20229 {
20230 int32_t map = args[0];
20231 int32_t screen = args[1];
20232 int32_t flag = args[2];
20233 bool value = args[3];
20234
20235 if (unsigned(flag)>=mMAXIND)
20236 {
20237 Z_error("SCC: Screen state %d is invalid\n", flag);
20238 return true;
20239 }
20240
20241 if (map < 1 || map > map_count)
20242 {
20243 Z_error("SCC: Map %d is invalid\n", map);
20244 return true;
20245 }
20246
20247 if (unsigned(screen)>=0x80)
20248 {
20249 Z_error("SCC: Screen %d is invalid\n", screen);
20250 return true;
20251 }
20252
20253 int mi = mapind(map, screen);
20254 bool state = (game->maps[mi] & (1<<flag)) != 0;
20255 if (state == value)
20256 {
20257 last_arg = 4;
20258 goto switched;
20259 }
20260
20261 return true;
20262 }
20263
20264 case MSGC_GOTOIFSCREENEXSTATE:
20265 {
20266 int32_t flag = args[0];
20267 bool value = args[1];
20268
20269 if (unsigned(flag) >= 32)
20270 {
20271 Z_error("SCC: Screen ExState %d is invalid\n", flag);
20272 return true;
20273 }
20274
20275 bool state = getxmapflag(msgscr->screen, 1<<flag);
20276 if (state == value)
20277 {
20278 last_arg = 2;
20279 goto switched;
20280 }
20281
20282 return true;
20283 }
20284
20285 case MSGC_GOTOIFANYSCREENEXSTATE:
20286 {
20287 int32_t map = args[0];
20288 int32_t screen = args[1];
20289 int32_t flag = args[2];
20290 bool value = args[3];
20291
20292 if (unsigned(flag) >= 32)
20293 {
20294 Z_error("SCC: Screen ExState %d is invalid\n", flag);
20295 return true;
20296 }
20297
20298 if (map < 1 || map > map_count)
20299 {
20300 Z_error("SCC: Map %d is invalid\n", map);
20301 return true;
20302 }
20303
20304 if (unsigned(screen)>=0x80)
20305 {
20306 Z_error("SCC: Screen %d is invalid\n", screen);
20307 return true;
20308 }
20309
20310 bool state = getxmapflag(mapind(map, screen), 1<<flag);
20311 if (state == value)
20312 {
20313 last_arg = 4;
20314 goto switched;
20315 }
20316
20317 return true;
20318 }
20319
20320 case MSGC_GOTOIFLEVELSTATE:
20321 {
20322 int32_t level = args[0];
20323 int32_t flag = args[1];
20324 bool value = args[2];
20325
20326 if (level == -1)
20327 level = dlevel;
20328
20329 if (unsigned(level) >= game->lvlswitches.size())
20330 {
20331 Z_error("SCC: Level %d is invalid\n", level);
20332 return true;
20333 }
20334
20335 if (unsigned(flag) >= 32)
20336 {
20337 Z_error("SCC: Level state %d is invalid\n", flag);
20338 return true;
20339 }
20340
20341 bool state = game->lvlswitches[level] & (1<<flag);
20342 if (state == value)
20343 {
20344 last_arg = 3;
20345 goto switched;
20346 }
20347
20348 return true;
20349 }
20350
20351 case MSGC_SETLEVELSTATE:
20352 {
20353 int32_t level = args[0];
20354 int32_t flag = args[1];
20355 bool value = args[2];
20356
20357 if (level == -1)
20358 level = dlevel;
20359
20360 if (unsigned(level) >= game->lvlswitches.size())
20361 {
20362 Z_error("SCC: Level %d is invalid\n", level);
20363 return true;
20364 }
20365
20366 if (unsigned(flag) >= 32)
20367 {
20368 Z_error("SCC: Level state %d is invalid\n", flag);
20369 return true;
20370 }
20371
20372 if (level == dlevel)
20373 {
20374 if (bool(game->lvlswitches[level] & (1<<flag)) != value)
20375 toggle_switches(1<<flag, false);
20376 }
20377 else
20378 {
20379 SETFLAG(game->lvlswitches[level], 1<<flag, value);
20380 }
20381
20382 return true;
20383 }
20384
20385 case MSGC_GOTOIFLEVELITEM:
20386 {
20387 int32_t level = args[0];
20388 int32_t flag = args[1];
20389 bool value = args[2];
20390
20391 if (level == -1)
20392 level = dlevel;
20393
20394 if (unsigned(level) >= game->lvlitems.size())
20395 {
20396 Z_error("SCC: Level %d is invalid\n", level);
20397 return true;
20398 }
20399
20400 if (unsigned(flag) >= 16)
20401 {
20402 Z_error("SCC: Level item %d is invalid\n", flag);
20403 return true;
20404 }
20405
20406 bool state = game->lvlitems[level] & (1<<flag);
20407 if (state == value)
20408 {
20409 last_arg = 3;
20410 goto switched;
20411 }
20412
20413 return true;
20414 }
20415
20416 case MSGC_SETLEVELITEM:
20417 {
20418 int32_t level = args[0];
20419 int32_t flag = args[1];
20420 bool value = args[2];
20421
20422 if (level == -1)
20423 level = dlevel;
20424
20425 if (unsigned(level) >= game->lvlitems.size())
20426 {
20427 Z_error("SCC: Level %d is invalid\n", level);
20428 return true;
20429 }
20430
20431 if (unsigned(flag) >= 16)
20432 {
20433 Z_error("SCC: Level item %d is invalid\n", flag);
20434 return true;
20435 }
20436
20437 SETFLAG(game->lvlitems[level], 1<<flag, value);
20438
20439 return true;
20440 }
20441
20442 case MSGC_GOTOIFSECRETS:
20443 {
20444 if (get_screen_state(msgscr->screen).triggered_secrets)
20445 {
20446 last_arg = 0;
20447 goto switched;
20448 }
20449
20450 return true;
20451 }
20452
20453 case MSGC_GOTOIFCREEND:
20454 {
20455 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20456 int32_t screen = args[1];
20457 int32_t reg = args[2];
20458 int32_t val = args[3];
20459 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20460 {
20461 last_arg = 4;
20462 goto switched;
20463 }
20464 return true;
20465 }
20466
20467 case MSGC_GOTOIFITEM:
20468 {
20469 123 int32_t it = args[0];
20470
20471
3/4
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 35 times.
123 if(unsigned(it)<MAXITEMS && game->item[it])
20472 {
20473 35 last_arg = 1;
20474 35 goto switched;
20475 }
20476
20477 88 return true;
20478 }
20479
20480 case MSGC_GOTOIFCTR:
20481 {
20482
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20483 {
20484 14 last_arg = 2;
20485 14 goto switched;
20486 }
20487
20488 14 return true;
20489 }
20490
20491 case MSGC_GOTOIFCTRPC:
20492 {
20493 int32_t counter = args[0];
20494 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20495
20496 if(game->get_counter(counter)>=amount)
20497 {
20498 last_arg = 2;
20499 goto switched;
20500 }
20501
20502 return true;
20503 }
20504
20505 case MSGC_GOTOIFTRICOUNT:
20506 {
20507 if(TriforceCount() >= args[0])
20508 {
20509 last_arg = 1;
20510 goto switched;
20511 }
20512
20513 return true;
20514 }
20515
20516 case MSGC_GOTOIFTRI:
20517 {
20518 int32_t lev = args[0];
20519
20520 if(lev<MAXLEVELS && game->lvlitems[lev]&(1 << li_mcguffin))
20521 {
20522 last_arg = 1;
20523 goto switched;
20524 }
20525
20526 return true;
20527 }
20528
20529 case MSGC_GOTOIFBOTTLE:
20530 {
20531 int quant = args[0];
20532 int type = args[1];
20533 if (game->hasBottle(type, quant))
20534 {
20535 last_arg = 2;
20536 goto switched;
20537 }
20538 return true;
20539 }
20540 case MSGC_CHANGEBOTTLE:
20541 {
20542 int quant = args[0];
20543 int old_type = args[1];
20544 int new_type = args[2];
20545 game->fillBottle(new_type, old_type, quant);
20546 return true;
20547 }
20548
20549 case MSGC_CHANGEPORTRAIT:
20550 {
20551 prt_tile = args[0];
20552 prt_cset = args[1];
20553 prt_x = args[2];
20554 prt_y = args[3];
20555 prt_tw = args[4];
20556 prt_th = args[5];
20557 msg_prt();
20558 return true;
20559 }
20560
20561 case MSGC_SETUPMENU:
20562 {
20563 6 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20564 6 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20565 6 msg_menu_data[MNU_CURSOR_WID] = args[2];
20566 6 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20567 6 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20568 6 return true;
20569 }
20570
20571 case MSGC_MENUCHOICE:
20572 {
20573 24 int32_t pos = args[0];
20574 24 int32_t upos = args[1];
20575 24 int32_t dpos = args[2];
20576 24 int32_t lpos = args[3];
20577 24 int32_t rpos = args[4];
20578
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2 times.
24 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20579 {
20580 2 ssc_tile_hei = ssc_tile_hei_buf;
20581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20582 2 ssc_tile_hei_buf = -1;
20583 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20585 2 cursor_x=msg_margins[left];
20586 2 }
20587
20588 48 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20589 24 upos, dpos, lpos, rpos);
20590
20591
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20592 24 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20593 24 return true;
20594 }
20595
20596 case MSGC_RUNMENU:
20597 {
20598 6 msg_menu_data[MNU_CHOSEN] = 0;
20599 6 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(menu_options.size() < 1)
20601 return true;
20602 6 do_run_menu = true;
20603 6 return true;
20604 }
20605
20606 case MSGC_GOTOMENUCHOICE:
20607 {
20608 8 int32_t choice = args[0];
20609
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(msg_menu_data[MNU_CHOSEN] == choice)
20610 {
20611 6 last_arg = 1;
20612 6 goto switched;
20613 }
20614
20615 2 return true;
20616 }
20617
20618 case MSGC_KILLHERO:
20619 {
20620 bool bypass_revive = args[0];
20621 Hero.kill(bypass_revive);
20622 return true;
20623 }
20624 case MSGC_ENDSTRING:
20625 {
20626 3 do_end_str = true;
20627 3 return true;
20628 }
20629 case MSGC_WAIT_ADVANCE:
20630 {
20631 wait_advance = true;
20632 linkedmsgclk = 51;
20633 return true;
20634 }
20635 case MSGC_DELAY:
20636 case MSGC_FORCE_DELAY:
20637 {
20638 2 int frames = args[0];
20639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (frames <= 0)
20640 {
20641 Z_error("SCC: frames %d is invalid (must be >0)\n", frames);
20642 return true;
20643 }
20644
20645 2 msg_it->set_post_segment_delay(frames, command.code == MSGC_FORCE_DELAY);
20646 2 return true;
20647 }
20648 case MSGC_TRIGSECRETS:
20649 {
20650 bool perm = args[0];
20651 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20652 if(perm)
20653 setmapflag(msgscr, mSECRET);
20654 return true;
20655 }
20656 case MSGC_TRIG_CMB_COPYCAT:
20657 {
20658 int copy_id = args[0];
20659 if(copy_id == byte(copy_id))
20660 trig_copycat(copy_id);
20661 return true;
20662 }
20663 case MSGC_SETSCREENSTATE:
20664 {
20665 int32_t flag = args[0];
20666 if(unsigned(flag)>=mMAXIND)
20667 {
20668 Z_error("SCC 133: State %d is invalid\n", flag);
20669 return true;
20670 }
20671 bool state = args[1];
20672 if(state)
20673 setmapflag(msgscr, 1<<flag);
20674 else
20675 unsetmapflag(msgscr, 1<<flag, true);
20676 return true;
20677 }
20678 case MSGC_SETSCREENSTATER:
20679 {
20680 int32_t map = args[0];
20681 int32_t scrid = args[1];
20682 if(map < 1 || map > map_count)
20683 {
20684 Z_error("SCC 134: Map %d is invalid\n", map);
20685 return true;
20686 }
20687 if(unsigned(scrid)>=0x80)
20688 {
20689 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20690 return true;
20691 }
20692
20693 int32_t flag = args[2];
20694 if(unsigned(flag)>=mMAXIND)
20695 {
20696 Z_error("SCC 134: State %d is invalid\n", flag);
20697 return true;
20698 }
20699 bool state = args[3];
20700 if(state)
20701 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20702 else
20703 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20704 return true;
20705 }
20706
20707 case MSGC_SETANYSCREENEXSTATE:
20708 {
20709 int32_t map = args[0];
20710 int32_t screen = args[1];
20711 int32_t flag = args[2];
20712
20713 if (unsigned(flag) >= 32)
20714 {
20715 Z_error("SCC: Screen ExState %d is invalid\n", flag);
20716 return true;
20717 }
20718
20719 if (map < 1 || map > map_count)
20720 {
20721 Z_error("SCC: Map %d is invalid\n", map);
20722 return true;
20723 }
20724
20725 if (unsigned(screen)>=0x80)
20726 {
20727 Z_error("SCC: Screen %d is invalid\n", screen);
20728 return true;
20729 }
20730
20731 bool state = args[3];
20732 if(state)
20733 setxmapflag(mapind(map, screen), 1<<flag);
20734 else
20735 unsetxmapflag(mapind(map, screen), 1<<flag);
20736 return true;
20737 }
20738
20739 case MSGC_SETSCREENEXSTATE:
20740 {
20741 int32_t flag = args[0];
20742 if (unsigned(flag) >= 32)
20743 {
20744 Z_error("SCC: Screen ExState %d is invalid\n", flag);
20745 return true;
20746 }
20747
20748 bool state = args[1];
20749 if(state)
20750 setxmapflag(msgscr->screen, 1<<flag);
20751 else
20752 unsetxmapflag(msgscr->screen, 1<<flag);
20753 return true;
20754 }
20755
20756 switched:
20757 56 int32_t lev = args[last_arg];
20758
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
56 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20759
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 33 times.
55 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20760 {
20761 setmsg(lev);
20762 }
20763 else
20764 {
20765 56 donewmsg(msgscr, lev);
20766 56 ssc_tile_hei_buf = -1;
20767 }
20768 56 putprices(false);
20769 56 return true;
20770 }
20771
20772 return false;
20773 3751 }
20774
20775 3761 static std::string parsemsgcode2(const StringCommand& command)
20776 {
20777
2/2
✓ Branch 0 taken 3755 times.
✓ Branch 1 taken 6 times.
3761 if (command.code == MSGC_NAME)
20778 {
20779
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20780 }
20781
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3753 times.
3755 else if (command.code == MSGC_COUNTER)
20782 {
20783 2 return fmt::format("{}", game->get_counter(command.args[0]));
20784 }
20785
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3751 times.
3753 else if (command.code == MSGC_MAXCOUNTER)
20786 {
20787 2 return fmt::format("{}", game->get_maxcounter(command.args[0]));
20788 }
20789 else
20790 {
20791 3751 parsemsgcode(command);
20792 }
20793
20794
1/2
✓ Branch 0 taken 3751 times.
✗ Branch 1 not taken.
3751 return "";
20795 3761 }
20796
20797 292708 static bool putmsgchar(bool play_sfx)
20798 {
20799 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20800 DCHECK(!msg_it->character.empty());
20801
20802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292708 times.
292708 if (bottom_margin_clip())
20803 return false;
20804
20805 // If the current word would overflow the margins, increment cursor to the next line.
20806 292708 const char* rem_word = msg_it->remaining_word();
20807 292708 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20808
4/4
✓ Branch 0 taken 6443 times.
✓ Branch 1 taken 286265 times.
✓ Branch 2 taken 1147 times.
✓ Branch 3 taken 5089 times.
298944 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20809
4/4
✓ Branch 0 taken 6236 times.
✓ Branch 1 taken 207 times.
✓ Branch 2 taken 5089 times.
✓ Branch 3 taken 207 times.
6443 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20810 {
20811 6236 ssc_tile_hei = ssc_tile_hei_buf;
20812
1/2
✓ Branch 0 taken 6236 times.
✗ Branch 1 not taken.
6236 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20813 6236 ssc_tile_hei_buf = -1;
20814 6236 cursor_y += thei + MsgStrings[msgstr].vspace;
20815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6236 times.
6236 if (bottom_margin_clip()) return false;
20816
20817 6236 cursor_x = msg_margins[left];
20818 6236 }
20819
20820
2/2
✓ Branch 0 taken 40287 times.
✓ Branch 1 taken 252421 times.
292708 if (play_sfx)
20821 252421 sfx(MsgStrings[msgstr].sfx);
20822
20823 // Print the character (unless it's just a space).
20824
2/2
✓ Branch 0 taken 66650 times.
✓ Branch 1 taken 226058 times.
292708 if (msg_it->character != " ")
20825 226058 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, ALIGN_LEFT, msgcolour, msg_shdcol, -1);
20826
20827 // Move the cursor.
20828 292708 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20829
2/2
✓ Branch 0 taken 66650 times.
✓ Branch 1 taken 226058 times.
292708 if (msg_it->character != " ")
20830 226058 cursor_x += MsgStrings[msgstr].hspace;
20831
20832 292708 return true;
20833 292708 }
20834
20835 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20836
20837 static void msg_tick_end(bool disappear = false);
20838 281768 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20839 {
20840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 281768 times.
281768 if (msg_it->done())
20841 return msg_tick_exit;
20842
20843
2/2
✓ Branch 0 taken 2117 times.
✓ Branch 1 taken 279651 times.
281768 if (!do_run_menu)
20844 {
20845
4/4
✓ Branch 0 taken 279645 times.
✓ Branch 1 taken 3761 times.
✓ Branch 2 taken 279645 times.
✓ Branch 3 taken 3761 times.
283406 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20846 {
20847 3761 bool one_frame_command_delay = !replay_version_check(41);
20848 3761 std::string text = parsemsgcode2(msg_it->command);
20849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3761 times.
3761 if (wait_advance)
20850 break;
20851
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3755 times.
3761 if (do_run_menu)
20852 {
20853
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 msg_it->set_buffer("");
20854 6 break;
20855 }
20856
20857
2/2
✓ Branch 0 taken 3745 times.
✓ Branch 1 taken 10 times.
3755 if (text.empty())
20858 {
20859
2/4
✓ Branch 0 taken 3745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3745 times.
✗ Branch 3 not taken.
3745 msg_it->set_buffer("");
20860 // Advance the iterator to run many commands in one frame.
20861
2/2
✓ Branch 0 taken 634 times.
✓ Branch 1 taken 3111 times.
3745 if (!one_frame_command_delay)
20862
1/2
✓ Branch 0 taken 634 times.
✗ Branch 1 not taken.
634 msg_it->next();
20863 3745 }
20864 else
20865 {
20866
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 msg_it->set_buffer(text);
20867
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 msg_it->next();
20868
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
10 if (one_frame_command_delay)
20869
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->set_post_segment_delay(1, false);
20870 }
20871
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 3755 times.
3761 }
20872
20873
2/2
✓ Branch 0 taken 3390 times.
✓ Branch 1 taken 276261 times.
279651 if (msg_it->state == MsgStr::iterator::CHARACTER)
20874 {
20875
1/2
✓ Branch 0 taken 276261 times.
✗ Branch 1 not taken.
276261 if (!putmsgchar(play_sfx)) return msg_tick_break;
20876 276261 }
20877 279651 }
20878
20879 281768 bool wait_advance_check_early = !burst_mode;
20880
20881
2/2
✓ Branch 0 taken 105604 times.
✓ Branch 1 taken 176164 times.
281768 if (wait_advance_check_early)
20882 {
20883
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 176163 times.
176164 if (do_end_str)
20884 {
20885 1 msg_tick_end();
20886 1 return msg_tick_exit;
20887 }
20888
20889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 176163 times.
176163 if (wait_advance)
20890 {
20891 msg_it->next();
20892 return msg_tick_exit;
20893 }
20894 176163 }
20895
20896
2/2
✓ Branch 0 taken 279644 times.
✓ Branch 1 taken 2123 times.
281767 if (do_run_menu)
20897 {
20898
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2117 times.
2123 if (runMenuCursor())
20899 {
20900 6 do_run_menu = false;
20901
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if (!burst_mode)
20902 {
20903 2 msg_it->next();
20904 2 return msg_tick(play_sfx, burst_mode);
20905 }
20906 4 }
20907 2117 else return msg_tick_break;
20908 4 }
20909
20910 279648 msg_it->next();
20911
20912
2/2
✓ Branch 0 taken 174621 times.
✓ Branch 1 taken 105027 times.
279648 if (!wait_advance_check_early)
20913 {
20914
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 105024 times.
105027 if (do_end_str)
20915 {
20916 3 msg_tick_end();
20917 3 return msg_tick_exit;
20918 }
20919
20920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105024 times.
105024 if (wait_advance)
20921 return msg_tick_exit;
20922 105024 }
20923
20924
4/4
✓ Branch 0 taken 4388 times.
✓ Branch 1 taken 275257 times.
✓ Branch 2 taken 2122 times.
✓ Branch 3 taken 2266 times.
279645 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20925 {
20926
1/2
✓ Branch 0 taken 2122 times.
✗ Branch 1 not taken.
2122 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20927 setmsg(MsgStrings[msgstr].nextstring);
20928 2122 }
20929
20930 279645 return msg_tick_continue;
20931 281768 }
20932
20933 179014 static void msg_tick_end(bool disappear)
20934 {
20935
2/2
✓ Branch 0 taken 177724 times.
✓ Branch 1 taken 1290 times.
179014 if (disappear)
20936 1290 goto disappear;
20937
20938 // Done printing the string
20939
8/8
✓ Branch 0 taken 177720 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 176180 times.
✓ Branch 3 taken 1540 times.
✓ Branch 4 taken 171773 times.
✓ Branch 5 taken 4407 times.
✓ Branch 6 taken 171773 times.
✓ Branch 7 taken 4407 times.
177724 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
20940 {
20941
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4407 times.
4411 if(!do_end_str)
20942 {
20943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4407 times.
4407 while (msg_it->state == MsgStr::iterator::COMMAND)
20944 {
20945 parsemsgcode2(msg_it->command);
20946 msg_it->next();
20947 }
20948 4407 }
20949
20950 // Go to next string, or make it disappear by going to string 0.
20951
5/6
✓ Branch 0 taken 2287 times.
✓ Branch 1 taken 2124 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 1291 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 996 times.
4411 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
20952 {
20953 3415 linkedmsgclk=do_end_str?1:51;
20954 3415 }
20955
20956
2/2
✓ Branch 0 taken 2287 times.
✓ Branch 1 taken 2124 times.
4411 if(MsgStrings[msgstr].nextstring==0)
20957 {
20958
2/2
✓ Branch 0 taken 1291 times.
✓ Branch 1 taken 996 times.
2287 if(!get_qr(qr_MSGDISAPPEAR))
20959 996 {
20960 disappear:
20961 2286 msg_active = false;
20962 2286 Hero.finishedmsg();
20963 2286 }
20964
20965
2/2
✓ Branch 0 taken 3564 times.
✓ Branch 1 taken 13 times.
3577 if(repaircharge)
20966 {
20967
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
20968 13 repaircharge = 0;
20969 13 }
20970
20971
2/2
✓ Branch 0 taken 3575 times.
✓ Branch 1 taken 2 times.
3577 if(adjustmagic)
20972 {
20973
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
20974 {
20975
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
20976 2 game->set_magicdrainrate(1);
20977 2 }
20978 else if(game->get_magicdrainrate() > 1)
20979 {
20980 game->set_magicdrainrate(game->get_magicdrainrate()/2);
20981 }
20982 2 adjustmagic = false;
20983 2 sfx(WAV_SCALE);
20984
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20985 2 }
20986
20987
2/2
✓ Branch 0 taken 3575 times.
✓ Branch 1 taken 2 times.
3577 if(learnslash)
20988 {
20989 2 game->set_canslash(1);
20990 2 learnslash = false;
20991 2 sfx(WAV_SCALE);
20992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20993 2 }
20994 3577 }
20995 5701 }
20996 179014 }
20997
20998 6618 static void msg_consume_spaces()
20999 {
21000
2/2
✓ Branch 0 taken 6618 times.
✓ Branch 1 taken 16447 times.
23065 while (msg_it->character == " ")
21001 {
21002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16447 times.
16447 if (!putmsgchar(false)) break;
21003
21004 // Advance the iterator.
21005 16447 msg_it->next();
21006
21007 // The "Continue From Previous" feature
21008
1/2
✓ Branch 0 taken 16447 times.
✗ Branch 1 not taken.
16447 if (msg_it->state == MsgStr::iterator::DONE)
21009 {
21010 if(MsgStrings[msgstr].nextstring)
21011 {
21012 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21013 {
21014 setmsg(MsgStrings[msgstr].nextstring);
21015 }
21016 }
21017 }
21018 }
21019 6618 }
21020
21021 15197177 void putmsg()
21022 {
21023
2/2
✓ Branch 0 taken 733364 times.
✓ Branch 1 taken 14463813 times.
15197177 if(!msgorig) msgorig=msgstr;
21024
21025
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15197177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15197177 if(wait_advance && linkedmsgclk < 1)
21026 linkedmsgclk = 1;
21027
2/2
✓ Branch 0 taken 14884136 times.
✓ Branch 1 taken 313041 times.
15197177 if(linkedmsgclk>0)
21028 {
21029
2/2
✓ Branch 0 taken 142540 times.
✓ Branch 1 taken 170501 times.
313041 if(linkedmsgclk==1)
21030 {
21031
6/6
✓ Branch 0 taken 142536 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 139263 times.
✓ Branch 3 taken 3273 times.
✓ Branch 4 taken 136 times.
✓ Branch 5 taken 139127 times.
142540 if(do_end_str || getInput(btnA) || getInput(btnB))
21032 {
21033 3413 do_end_str = false;
21034 3413 linkedmsgclk = 0;
21035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3413 times.
3413 if(wait_advance)
21036 {
21037 wait_advance = false;
21038 }
21039 else
21040 {
21041
2/2
✓ Branch 0 taken 3412 times.
✓ Branch 1 taken 1 times.
3413 if (!msgscr) msgscr = hero_scr;
21042 3413 msgstr=MsgStrings[msgstr].nextstring;
21043 3413 ssc_tile_hei_buf = -1;
21044
3/4
✓ Branch 0 taken 1290 times.
✓ Branch 1 taken 2123 times.
✓ Branch 2 taken 1290 times.
✗ Branch 3 not taken.
3413 if(!msgstr && enqueued_str)
21045 {
21046 msgstr = enqueued_str;
21047 enqueued_str = 0;
21048 }
21049
2/2
✓ Branch 0 taken 2123 times.
✓ Branch 1 taken 1290 times.
3413 if(!msgstr)
21050 {
21051 1290 msgfont=get_zc_font(font_zfont);
21052
21053
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1286 times.
1290 if(msgscr->room!=rGRUMBLE)
21054 1286 blockpath=false;
21055
21056 1290 dismissmsg();
21057 1290 msg_tick_end(true);
21058 1290 return;
21059 }
21060
21061 2123 donewmsg(msgscr, msgstr);
21062 2123 putprices(false);
21063 }
21064 2123 }
21065 141250 }
21066 else
21067 {
21068 170501 --linkedmsgclk;
21069 }
21070 311751 }
21071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15195887 times.
15195887 if(wait_advance) return; //Waiting for buttonpress
21072
21073
9/10
✓ Branch 0 taken 15194251 times.
✓ Branch 1 taken 1636 times.
✓ Branch 2 taken 728219 times.
✓ Branch 3 taken 14466032 times.
✓ Branch 4 taken 280783 times.
✓ Branch 5 taken 447436 times.
✓ Branch 6 taken 276377 times.
✓ Branch 7 taken 4406 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 276377 times.
15195887 if(!do_run_menu && (!msgstr || !msg_it || msg_it->done() || bottom_margin_clip()))
21074 {
21075
2/2
✓ Branch 0 taken 451842 times.
✓ Branch 1 taken 14466032 times.
14917874 if(!msgstr)
21076 14466032 msgorig=0;
21077
21078 14917874 msg_active = false;
21079 14917874 msg_it.reset();
21080 14917874 return;
21081 }
21082
21083
1/2
✓ Branch 0 taken 278013 times.
✗ Branch 1 not taken.
278013 if (!msg_it)
21084 return;
21085
21086 278013 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
21087
21088
2/2
✓ Branch 0 taken 273582 times.
✓ Branch 1 taken 4431 times.
278013 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
21089 {
21090 4431 msg_it->next();
21091 4431 msg_consume_spaces();
21092 4431 }
21093
21094 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
21095 // as possible. This skips the character-by-character animation that usually renders a string
21096 // slowly over many frames.
21097
4/4
✓ Branch 0 taken 1666 times.
✓ Branch 1 taken 276347 times.
✓ Branch 2 taken 275771 times.
✓ Branch 3 taken 576 times.
278013 if ((getInput(btnB) && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
21098 {
21099
2/2
✓ Branch 0 taken 1559 times.
✓ Branch 1 taken 105611 times.
107266 while (!msg_it->done())
21100 {
21101
5/6
✓ Branch 0 taken 47640 times.
✓ Branch 1 taken 57971 times.
✓ Branch 2 taken 47633 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 47633 times.
✗ Branch 5 not taken.
105611 if (msgspeed && !(getInput(btnB) && get_qr(qr_ALLOWMSGBYPASS)))
21102 7 goto breakout; // break out if message speed was changed to non-zero
21103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 105604 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
105604 if (msg_it->get_post_segment_delay() && msg_it->get_post_segment_delay_forced())
21104 goto breakout; // or if a ForceDelay command was hit.
21105
21106 105604 auto tick = msg_tick(msg_it->character != " ", true);
21107
2/2
✓ Branch 0 taken 105027 times.
✓ Branch 1 taken 577 times.
105604 if (tick == msg_tick_break)
21108 577 break;
21109
2/2
✓ Branch 0 taken 105024 times.
✓ Branch 1 taken 3 times.
105027 if (tick == msg_tick_exit)
21110 3 return;
21111 }
21112
21113
2/2
✓ Branch 0 taken 577 times.
✓ Branch 1 taken 1559 times.
2136 if (!do_run_menu)
21114 {
21115 1559 msgclk = 72;
21116 1559 }
21117 2136 }
21118 else
21119 275771 {
21120 breakout:
21121 275778 word tempspeed = msgspeed;
21122
2/2
✓ Branch 0 taken 70445 times.
✓ Branch 1 taken 205333 times.
275778 bool go_fast = get_qr(qr_ALLOWFASTMSG) && getInput(btnA);
21123
2/2
✓ Branch 0 taken 274815 times.
✓ Branch 1 taken 963 times.
275778 if (do_run_menu)
21124 963 tempspeed = 0;
21125
6/6
✓ Branch 0 taken 275509 times.
✓ Branch 1 taken 269 times.
✓ Branch 2 taken 275509 times.
✓ Branch 3 taken 269 times.
✓ Branch 4 taken 275542 times.
✓ Branch 5 taken 236 times.
275778 if (msg_it->get_post_segment_delay() && msg_it->peek(0).empty())
21126 {
21127 236 tempspeed = 0;
21128 236 msg_it->set_post_segment_delay_fast(go_fast);
21129 236 }
21130
4/4
✓ Branch 0 taken 216670 times.
✓ Branch 1 taken 59108 times.
✓ Branch 2 taken 116477 times.
✓ Branch 3 taken 100193 times.
275778 if ((msgclk++ % (tempspeed+1) < tempspeed) && !go_fast)
21131 100193 return;
21132 }
21133
21134 // Process the next msg tick.
21135 // This will either print a single character, or process a single string command (with one
21136 // exception).
21137
3/4
✓ Branch 0 taken 176162 times.
✓ Branch 1 taken 1559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176162 times.
177721 if (!msg_it->done() && !bottom_margin_clip())
21138 {
21139 // This may run an additional tick in the case of a string menu finishing: the first
21140 // tick wraps up the menu, and then a second tick processes the next character or command.
21141 176162 auto tick = msg_tick(true, false);
21142
2/2
✓ Branch 0 taken 1540 times.
✓ Branch 1 taken 174622 times.
176162 if (tick == msg_tick_break)
21143 {
21144 1540 msg_tick_end();
21145 1540 return;
21146 }
21147
2/2
✓ Branch 0 taken 174621 times.
✓ Branch 1 taken 1 times.
174622 if (tick == msg_tick_exit)
21148 1 return;
21149
21150 // If the next two characters are spaces, consume all upcoming spaces now.
21151
13/20
✓ Branch 0 taken 2848 times.
✓ Branch 1 taken 171773 times.
✓ Branch 2 taken 171773 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28500 times.
✓ Branch 5 taken 143273 times.
✓ Branch 6 taken 28500 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 28500 times.
✓ Branch 10 taken 146121 times.
✓ Branch 11 taken 28500 times.
✓ Branch 12 taken 2848 times.
✓ Branch 13 taken 171773 times.
✓ Branch 14 taken 172434 times.
✓ Branch 15 taken 2187 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
203121 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
21152 2187 msg_consume_spaces();
21153 174621 }
21154
21155 176180 msg_tick_end();
21156 15197081 }
21157
21158 140544 int32_t message_more_y()
21159 {
21160 //Is the flag ticked, do we really want a message more y larger than 160?
21161
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 140516 times.
✓ Branch 2 taken 140544 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140516 times.
✓ Branch 5 taken 28 times.
140544 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21162 140544 msgy+=playing_field_offset;
21163 140544 return msgy;
21164 }
21165
21166 /*** Collision detection & handling ***/
21167
21168 14834120 void clear_script_one_frame_conditions()
21169 {
21170
2/2
✓ Branch 0 taken 40035761 times.
✓ Branch 1 taken 14834120 times.
54869881 for(int32_t j=0; j<guys.Count(); j++)
21171 {
21172 40035761 enemy *e = (enemy*)guys.spr(j);
21173
2/2
✓ Branch 0 taken 680607937 times.
✓ Branch 1 taken 40035761 times.
720643698 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21174 40035761 }
21175 14834120 }
21176
21177 6332453 void check_enemy_lweapon_collision(weapon *w)
21178 {
21179
8/8
✓ Branch 0 taken 5631760 times.
✓ Branch 1 taken 700693 times.
✓ Branch 2 taken 4578754 times.
✓ Branch 3 taken 1053006 times.
✓ Branch 4 taken 4511180 times.
✓ Branch 5 taken 67574 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 4494442 times.
6332453 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21180 {
21181
2/2
✓ Branch 0 taken 4478385 times.
✓ Branch 1 taken 14286019 times.
18764404 for(int32_t j=0; j<guys.Count(); j++)
21182 {
21183 14286019 enemy *e = (enemy*)guys.spr(j);
21184
21185 14286019 bool didhit = e->hit(w);
21186 //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21187 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21188
2/2
✓ Branch 0 taken 14057767 times.
✓ Branch 1 taken 228252 times.
14286019 if(didhit)
21189 {
21190 // !(e->stunclk)
21191 228252 int32_t h = e->takehit(w);
21192
2/2
✓ Branch 0 taken 193222 times.
✓ Branch 1 taken 35030 times.
228252 if (h < 0) // hitby code
21193 {
21194 35030 int indx = Lwpns.find(w);
21195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35030 times.
35030 if(indx > -1)
21196 35030 e->hitby[HIT_BY_LWEAPON] = indx+1;
21197 35030 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
21198 35030 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21199
2/2
✓ Branch 0 taken 32565 times.
✓ Branch 1 taken 2465 times.
35030 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].type;
21200 2465 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21201 35030 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21202 35030 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21203 //we may need to handle this in special cases. -Z
21204 // arrow item pierce flag, for example -Em
21205 35030 }
21206
21207
2/2
✓ Branch 0 taken 35030 times.
✓ Branch 1 taken 193222 times.
228252 if(h < 0) // hit, check if weapon is "out of pierces"
21208 35030 w->hit_pierce(e, h);
21209
2/2
✓ Branch 0 taken 182588 times.
✓ Branch 1 taken 10634 times.
193222 else if(h > 0) // blocked
21210 10634 w->onhit(false, e, h);
21211
2/2
✓ Branch 0 taken 225578 times.
✓ Branch 1 taken 2674 times.
228252 if(abs(h) == 2)
21212 2674 break; // some enemy classes force a weapon hitting them to "wait a frame"
21213 225578 }
21214
21215
2/2
✓ Branch 0 taken 14269962 times.
✓ Branch 1 taken 13383 times.
14283345 if(w->Dead())
21216 {
21217 13383 break;
21218 }
21219 14269962 }
21220
21221 // Item flags added in 2.55:
21222 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
21223 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21224 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21225 // -Em
21226
6/6
✓ Branch 0 taken 4031962 times.
✓ Branch 1 taken 462480 times.
✓ Branch 2 taken 3987048 times.
✓ Branch 3 taken 44914 times.
✓ Branch 4 taken 58271 times.
✓ Branch 5 taken 3928777 times.
4494442 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21227 {
21228 565665 int32_t itype, pitem = w->parentitem;
21229
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 462480 times.
✓ Branch 2 taken 58271 times.
✓ Branch 3 taken 44914 times.
565665 switch(w->id)
21230 {
21231 462480 case wBrang: itype = itype_brang; break;
21232 58271 case wArrow: itype = itype_arrow; break;
21233 case wHookshot:
21234 44914 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21235 44914 break;
21236 }
21237
2/2
✓ Branch 0 taken 550738 times.
✓ Branch 1 taken 14927 times.
565665 if(pitem < 0) pitem = current_item_id(itype);
21238
5/6
✓ Branch 0 taken 44914 times.
✓ Branch 1 taken 520751 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44814 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
565665 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
21239 { //Swap with item
21240 for(int32_t j=0; j<items.Count(); j++)
21241 {
21242 if(items.spr(j)->hit(w))
21243 {
21244 item *theItem = ((item*)items.spr(j));
21245 bool priced = theItem->PriceIndex >-1;
21246 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
21247 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
21248 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21249 {
21250 if(!Hero.switchhookclk)
21251 {
21252 hooked_comborpos = rpos_t::None;
21253 hooked_layerbits = 0;
21254 switching_object = theItem;
21255 theItem->switch_hooked = true;
21256 w->misc = 2;
21257 w->step = 0;
21258 theItem->clk2 = game->get_item_timeout_dur() / 2;
21259 Hero.doSwitchHook(game->get_switchhookstyle());
21260 if(QMisc.miscsfx[sfxSWITCHED])
21261 sfx(QMisc.miscsfx[sfxSWITCHED],pan(w->x));
21262 }
21263 }
21264 }
21265 }
21266 }
21267
6/6
✓ Branch 0 taken 58271 times.
✓ Branch 1 taken 507394 times.
✓ Branch 2 taken 374939 times.
✓ Branch 3 taken 316668 times.
✓ Branch 4 taken 507394 times.
✓ Branch 5 taken 316668 times.
565665 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21268 {
21269
2/2
✓ Branch 0 taken 88886 times.
✓ Branch 1 taken 374939 times.
463825 for(int32_t j=0; j<items.Count(); j++)
21270 {
21271
2/2
✓ Branch 0 taken 83988 times.
✓ Branch 1 taken 4898 times.
88886 if(items.spr(j)->hit(w))
21272 {
21273 4898 item *theItem = ((item*)items.spr(j));
21274 4898 bool priced = theItem->PriceIndex >-1;
21275
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
21276
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
21277
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
21278 {
21279
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
21280 {
21281 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21282 }
21283
21284 1724 Hero.checkitems(j);
21285 1724 }
21286 4898 }
21287 88886 }
21288 374939 }
21289
2/2
✓ Branch 0 taken 29180 times.
✓ Branch 1 taken 161546 times.
824062 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21290 {
21291
2/2
✓ Branch 0 taken 38285 times.
✓ Branch 1 taken 161546 times.
199831 for(int32_t j=0; j<items.Count(); j++)
21292 {
21293
2/2
✓ Branch 0 taken 29347 times.
✓ Branch 1 taken 8938 times.
38285 if(items.spr(j)->hit(w))
21294 {
21295 8938 item *theItem = ((item*)items.spr(j));
21296 8938 bool priced = theItem->PriceIndex >-1;
21297
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8931 times.
8938 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
21298
4/6
✓ Branch 0 taken 8938 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8938 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8655 times.
✓ Branch 5 taken 283 times.
8938 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= game->get_item_spawn_flicker())
21299
5/10
✓ Branch 0 taken 7455 times.
✓ Branch 1 taken 1200 times.
✓ Branch 2 taken 1483 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1483 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1483 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8938 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21300 {
21301 7455 int32_t pickup = theItem->pickup;
21302 7455 int32_t id2 = theItem->id;
21303 7455 int32_t pstr = theItem->pstring;
21304 7455 int32_t pstr_flags = theItem->pickup_string_flags;
21305
21306 7455 std::vector<int32_t> &ev = FFCore.eventData;
21307 7455 ev.clear();
21308 7455 ev.push_back(id2*10000);
21309 7455 ev.push_back(pickup*10000);
21310 7455 ev.push_back(pstr*10000);
21311 7455 ev.push_back(pstr_flags*10000);
21312 7455 ev.push_back(0);
21313 7455 ev.push_back(theItem->getUID());
21314 7455 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21315 7455 ev.push_back(w->getUID());
21316
21317 7455 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21318 7455 bool nullify = ev[4] != 0;
21319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7455 times.
7455 if(nullify) continue;
21320
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6379 times.
7455 if(w->id == wBrang)
21321 {
21322 6379 w->onhit(false);
21323 6379 }
21324
21325
2/2
✓ Branch 0 taken 6951 times.
✓ Branch 1 taken 504 times.
7455 if(w->dragging==-1)
21326 {
21327 504 w->dead=1;
21328 504 theItem->clk2 = game->get_item_timeout_dur() / 2;
21329 504 w->dragging=j;
21330 504 theItem->is_dragged = true;
21331 504 }
21332 7455 }
21333 8938 }
21334 38285 }
21335 161546 }
21336 565665 }
21337 4494442 }
21338 6332453 }
21339 14831917 void check_collisions()
21340 {
21341
2/2
✓ Branch 0 taken 6332418 times.
✓ Branch 1 taken 14831917 times.
21164335 for(uint q = 0; q < Lwpns.Count(); ++q)
21342 6332418 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
21343 14831917 }
21344
21345 14834120 void dragging_item()
21346 {
21347
2/2
✓ Branch 0 taken 6531126 times.
✓ Branch 1 taken 14834120 times.
21365246 for(int32_t i=0; i<Lwpns.Count(); i++)
21348 {
21349 6531126 weapon *w = (weapon*)Lwpns.spr(i);
21350
21351
4/4
✓ Branch 0 taken 6059972 times.
✓ Branch 1 taken 471154 times.
✓ Branch 2 taken 6367520 times.
✓ Branch 3 taken 163606 times.
6531126 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
21352 {
21353
3/4
✓ Branch 0 taken 7429 times.
✓ Branch 1 taken 156177 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7429 times.
163606 if(w->dragging>=0 && w->dragging<items.Count())
21354 {
21355 7429 item* dragItem = (item*)items.spr(w->dragging);
21356 7429 dragItem->x=w->x;
21357 7429 dragItem->y=w->y;
21358
21359 // Drag the Fairy enemy as well as the Fairy item
21360 7429 int32_t id = dragItem->id;
21361
21362
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 7010 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7429 if(itemsbuf[id].type ==itype_fairy && itemsbuf[id].misc3)
21363 {
21364 404 movefairynew2(w->x,w->y,*dragItem);
21365 404 }
21366 7429 }
21367 163606 }
21368 6531126 }
21369 14834120 }
21370
21371 64 int32_t more_carried_items(int screen)
21372 {
21373 64 int32_t hasmorecarries = 0;
21374
21375
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 64 times.
135 for(int32_t i=0; i<items.Count(); i++)
21376 {
21377 71 auto spr = (item*)items.spr(i);
21378
4/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 64 times.
71 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
21379 {
21380 64 hasmorecarries++;
21381 64 }
21382 71 }
21383
21384 64 return hasmorecarries;
21385 }
21386
21387 43413 static int count_guys_from_screen(int screen)
21388 {
21389 43413 int count = 0;
21390
2/2
✓ Branch 0 taken 244979 times.
✓ Branch 1 taken 43413 times.
288392 for (int i=0; i < guys.Count(); i++)
21391 {
21392
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 208441 times.
244979 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21393 208441 count += 1;
21394 244979 }
21395 43413 return count;
21396 }
21397
21398 // messy code to do the enemy-carrying-the-item thing
21399 15222048 static void roaming_item(mapscr* scr)
21400 {
21401 15222048 int screen = scr->screen;
21402 15222048 auto& state = get_screen_state(screen);
21403
4/4
✓ Branch 0 taken 15178704 times.
✓ Branch 1 taken 43344 times.
✓ Branch 2 taken 15178635 times.
✓ Branch 3 taken 43413 times.
15222048 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21404 15178635 return;
21405
21406 // All enemies already dead upon entering a room?
21407
1/2
✓ Branch 0 taken 43413 times.
✗ Branch 1 not taken.
43413 if (count_guys_from_screen(screen) == 0)
21408 {
21409 return;
21410 }
21411
21412 43413 int guycarryingitem = -1;
21413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91422 times.
91422 for(int32_t j=0; j<guys.Count(); j++)
21414 {
21415 91422 enemy* e = (enemy*)guys.spr(j);
21416
4/4
✓ Branch 0 taken 69728 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 43413 times.
91422 if (e->screen_spawned == screen && e->itemguy)
21417 {
21418 43413 guycarryingitem=j;
21419 43413 break;
21420 }
21421 48009 }
21422
21423
2/2
✓ Branch 0 taken 43329 times.
✓ Branch 1 taken 84 times.
43413 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21424 {
21425
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(guycarryingitem == -1) //This happens when "default enemies" such as
21426 {
21427 return; //eSHOOTFBALL are alive but enemies from the list
21428 } //are not. Defer to HeroClass::checkspecial().
21429
21430 84 int32_t Item=scr->item;
21431
21432 84 state.item_state = ScreenItemState::None;
21433
21434
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
84 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21435 {
21436 168 auto [x, y] = translate_screen_coordinates_to_world(screen);
21437 236 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21438
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 16 times.
84 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].type==itype_triforcepiece)) ? ipHOLDUP : 0)
21439 );
21440 84 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21441 84 state.item_state = ScreenItemState::CarriedByEnemy;
21442 84 }
21443 else
21444 {
21445 return;
21446 }
21447 84 }
21448
21449
2/2
✓ Branch 0 taken 52922 times.
✓ Branch 1 taken 43413 times.
96335 for(int32_t i=0; i<items.Count(); i++)
21450 {
21451
4/4
✓ Branch 0 taken 49311 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 43413 times.
52922 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21452 {
21453
2/2
✓ Branch 0 taken 29118 times.
✓ Branch 1 taken 14295 times.
43413 if(get_qr(qr_HIDECARRIEDITEMS))
21454 {
21455 29118 items.spr(i)->x = -128; // Awfully inelegant, innit?
21456 29118 items.spr(i)->y = -128;
21457 29118 }
21458
2/4
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14295 times.
14295 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21459 {
21460
1/2
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
14295 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21461 {
21462 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21463 {
21464 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21465 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21466 }
21467 else
21468 {
21469 if(guys.spr(guycarryingitem)->extend >= 3)
21470 {
21471 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21472 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21473 }
21474 else
21475 {
21476 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21477 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21478 }
21479 }
21480 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21481 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21482 }
21483 else
21484 {
21485 14295 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21486 14295 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21487 14295 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21488 }
21489 14295 }
21490 43413 }
21491 52922 }
21492 15222048 }
21493
21494 14834120 void roaming_item()
21495 {
21496 30056168 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21497 15222048 roaming_item(scr);
21498 15222048 });
21499 14834120 }
21500
21501 bool enemy::IsBigAnim()
21502 {
21503 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21504 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21505 || anim == a4FRM8DIRB);
21506 }
21507 2490371 int32_t enemy::getFlashingCSet()
21508 {
21509 //Special cset for the dying sprite
21510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2490371 times.
2490371 if(dying)
21511 {
21512 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21513 return wpnsbuf[spr_death].csets & 15;
21514 else
21515 return (((clk2 + 5) >> 1) & 3) + 6;
21516 }
21517
21518 //Normal cset
21519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2490371 times.
2490371 if (hclk <= 0)
21520 {
21521 //Special cset for the flashing animation
21522 if (flags & guy_flashing)
21523 return (frame & 3) + 6;
21524 return cs;
21525 }
21526
21527 //Hurt animations
21528
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2486483 times.
2490371 if(type==eeGANON)
21529 3888 return (((hclk-1)>>1)&3)+6;
21530
4/4
✓ Branch 0 taken 2312359 times.
✓ Branch 1 taken 174124 times.
✓ Branch 2 taken 554477 times.
✓ Branch 3 taken 1757882 times.
2486483 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21531 1757882 return (((hclk-1)>>1)&3)+6;
21532
21533 728601 return cs;
21534 2490371 }
21535
21536 83395497 bool enemy::is_hitflickerframe(bool olddrawing)
21537 {
21538
6/6
✓ Branch 0 taken 83366993 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 4085526 times.
✓ Branch 3 taken 79281467 times.
✓ Branch 4 taken 3199831 times.
✓ Branch 5 taken 885695 times.
83395497 if (type == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21539 82509802 return false;
21540
21541
3/4
✓ Branch 0 taken 609055 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 609055 times.
✗ Branch 3 not taken.
885695 if (!olddrawing && !getCanFlicker())
21542 return false;
21543
21544 885695 int32_t fr = game->get_spriteflickerspeed();
21545
1/2
✓ Branch 0 taken 885695 times.
✗ Branch 1 not taken.
885695 if (fr == 0)
21546 return true;
21547 885695 return frame % (fr * 2) < fr;
21548 83395497 }
21549
21550 const char *old_guy_string[OLDMAXGUYS] =
21551 {
21552 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21553 // 020
21554 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21555 // 025
21556 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21557 // 030
21558 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21559 // 035
21560 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21561 // 040
21562 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21563 // 045
21564 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21565 // 050
21566 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21567 // 055
21568 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21569 // 060
21570 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21571 // 065
21572 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21573 // 070
21574 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21575 // 075
21576 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21577 // 080
21578 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21579 // 085
21580 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21581 // 090
21582 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21583 // 095
21584 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21585 // 100
21586 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21587 // 105
21588 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21589 // 110
21590 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21591 // 115
21592 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21593 // 120
21594 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21595 // 125
21596 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21597 // 130
21598 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21599 // 135
21600 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21601 // 140
21602 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21603 // 145
21604 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21605 // 150
21606 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21607 // 155
21608 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21609 // 160
21610 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21611 // 165
21612 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21613 // 170
21614 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21615 // 175
21616 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21617 };
21618
21619 16717115 int32_t enemy::get_dmisc(byte index)
21620 {
21621
20/33
✓ Branch 0 taken 14611 times.
✓ Branch 1 taken 18181 times.
✓ Branch 2 taken 3236 times.
✓ Branch 3 taken 7390 times.
✓ Branch 4 taken 2144 times.
✓ Branch 5 taken 1799 times.
✓ Branch 6 taken 1056 times.
✓ Branch 7 taken 255 times.
✓ Branch 8 taken 1857 times.
✓ Branch 9 taken 1822 times.
✓ Branch 10 taken 8820348 times.
✓ Branch 11 taken 7597396 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 216 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 884 times.
✓ Branch 25 taken 1120 times.
✓ Branch 26 taken 336 times.
✓ Branch 27 taken 238061 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 6055 times.
✗ Branch 32 not taken.
16717115 switch (index)
21622 {
21623 14611 case 0: return dmisc1;
21624 18181 case 1: return dmisc2;
21625 3236 case 2: return dmisc3;
21626 7390 case 3: return dmisc4;
21627 2144 case 4: return dmisc5;
21628 1799 case 5: return dmisc6;
21629 1056 case 6: return dmisc7;
21630 255 case 7: return dmisc8;
21631 1857 case 8: return dmisc9;
21632 1822 case 9: return dmisc10;
21633 8820348 case 10: return dmisc11;
21634 7597396 case 11: return dmisc12;
21635 case 12: return dmisc13;
21636 308 case 13: return dmisc14;
21637 case 14: return dmisc15;
21638 40 case 15: return dmisc16;
21639 case 16: return dmisc17;
21640 216 case 17: return dmisc18;
21641 case 18: return dmisc19;
21642 case 19: return dmisc20;
21643 case 20: return dmisc21;
21644 case 21: return dmisc22;
21645 case 22: return dmisc23;
21646 case 23: return dmisc24;
21647 884 case 24: return dmisc25;
21648 1120 case 25: return dmisc26;
21649 336 case 26: return dmisc27;
21650 238061 case 27: return dmisc28;
21651 case 28: return dmisc29;
21652 case 29: return dmisc30;
21653 case 30: return dmisc31;
21654 6055 case 31: return dmisc32;
21655 }
21656
21657 return 0;
21658 16717115 }
21659
21660 312 void enemy::set_dmisc(byte index, int32_t value)
21661 {
21662
3/33
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 284 times.
✗ Branch 32 not taken.
312 switch (index)
21663 {
21664 case 0: dmisc1 = value; break;
21665 case 1: dmisc2 = value; break;
21666 case 2: dmisc3 = value; break;
21667 case 3: dmisc4 = value; break;
21668 case 4: dmisc5 = value; break;
21669 case 5: dmisc6 = value; break;
21670 case 6: dmisc7 = value; break;
21671 case 7: dmisc8 = value; break;
21672 case 8: dmisc9 = value; break;
21673 case 9: dmisc10 = value; break;
21674 case 10: dmisc11 = value; break;
21675 case 11: dmisc12 = value; break;
21676 case 12: dmisc13 = value; break;
21677 case 13: dmisc14 = value; break;
21678 case 14: dmisc15 = value; break;
21679 case 15: dmisc16 = value; break;
21680 case 16: dmisc17 = value; break;
21681 case 17: dmisc18 = value; break;
21682 case 18: dmisc19 = value; break;
21683 case 19: dmisc20 = value; break;
21684 case 20: dmisc21 = value; break;
21685 case 21: dmisc22 = value; break;
21686 case 22: dmisc23 = value; break;
21687 case 23: dmisc24 = value; break;
21688 case 24: dmisc25 = value; break;
21689 case 25: dmisc26 = value; break;
21690 4 case 26: dmisc27 = value; break;
21691 24 case 27: dmisc28 = value; break;
21692 case 28: dmisc28 = value; break;
21693 case 29: dmisc30 = value; break;
21694 case 30: dmisc31 = value; break;
21695 284 case 31: dmisc32 = value; break;
21696 }
21697 312 }
21698